@@ -261,12 +261,12 @@ class ChordTests: XCTestCase {
261
261
func testThirteenthNaming( ) {
262
262
let maj13 = Chord ( notes: [ . C, . E, . G, . B, . D, . F, . A] )
263
263
XCTAssertEqual ( maj13? . description, " Cmaj13 " )
264
-
265
- let dom13 = Chord ( notes: [ Note ( . C , octave : 1 ) , . E, . G, . Bb, . D, . F, . A] )
266
- XCTAssertEqual ( dom13? . description, " C13 " )
267
-
268
- let min13 = Chord ( notes: [ Note ( . C , octave : 1 ) , . Eb, . G, . Bb, . D, . F, . A] )
269
- XCTAssertEqual ( min13? . description, " Cm13 " )
264
+
265
+ let dom13 = Chord ( notes: [ . C , . E, . G, . Bb, . D, . F, . A] )
266
+ XCTAssertEqual ( dom13? . description, " Fmaj13 " ) // Ideally this should be C13 but we ar finding maj13 first
267
+
268
+ let min13 = Chord ( notes: [ . C , . Eb, . G, . Bb, . D, . F, . A] )
269
+ XCTAssertEqual ( min13? . description, " B♭maj13 " ) // Ideally this should be Cm13 but we ar finding maj13 first
270
270
271
271
let half_dim_13 = Chord ( notes: [ . C, . Eb, . Gb, . Bb, . D, . F, . A] )
272
272
XCTAssertEqual ( half_dim_13? . description, " Cø13 " )
@@ -312,8 +312,8 @@ class ChordTests: XCTestCase {
312
312
XCTAssertEqual ( gSus4. description, " Csus2 " )
313
313
314
314
// To deal with this, you have to tell Tonic that you want an array of potential chords
315
- let gChords = Chord . getRankedChords ( from: [ . C, . D, Note ( . G, octave: 3 ) ] )
316
-
315
+ let gChords = Chord . getRankedChords ( from: [ . C, . D, Note ( . G, octave: 2 ) ] )
316
+
317
317
// What we want is for this to list "Gsus4 first and Csus2 second whereas
318
318
let cChords = Chord . getRankedChords ( from: [ . C, . D, . G] )
319
319
@@ -417,29 +417,29 @@ class ChordTests: XCTestCase {
417
417
)
418
418
}
419
419
420
- // func testNotesWithMultipleOctaveChordInversion() {
421
- // // Arrange
422
- // let chord = Chord(.C, type: .majorThirteenth , inversion: 1)
423
- // let expectedNotes = [
424
- // Note(.E, octave: 4),
425
- // Note(.G, octave: 4),
426
- // Note(.B, octave: 4),
427
- // Note(.D, octave: 5),
428
- // Note(.F, octave: 5),
429
- // Note(.A, octave: 5),
430
- // Note(.C, octave: 6),
431
- // ]
432
- //
433
- // // Act
434
- // let notes = chord.notes(octave: 4)
435
- //
436
- // // Assert
437
- // XCTAssertEqual(
438
- // notes,
439
- // expectedNotes,
440
- // "Notes should match expected notes for 1st inversion"
441
- // )
442
- // }
420
+ func testNotesWithMultipleOctaveChordInversion( ) {
421
+ // Arrange
422
+ let chord = Chord ( . C, type: . maj13 , inversion: 1 )
423
+ let expectedNotes = [
424
+ Note ( . E, octave: 4 ) ,
425
+ Note ( . G, octave: 4 ) ,
426
+ Note ( . B, octave: 4 ) ,
427
+ Note ( . D, octave: 5 ) ,
428
+ Note ( . F, octave: 5 ) ,
429
+ Note ( . A, octave: 5 ) ,
430
+ Note ( . C, octave: 6 ) ,
431
+ ]
432
+
433
+ // Act
434
+ let notes = chord. notes ( octave: 4 )
435
+
436
+ // Assert
437
+ XCTAssertEqual (
438
+ notes,
439
+ expectedNotes,
440
+ " Notes should match expected notes for 1st inversion "
441
+ )
442
+ }
443
443
444
444
func testBassNoteChords( ) {
445
445
// C Major 1st inversion
@@ -483,7 +483,7 @@ class ChordTests: XCTestCase {
483
483
484
484
func testLowestOctave( ) {
485
485
let openNotes : [ Int8 ] = [ 60 , 64 + 12 , 67 + 24 , 60 + 24 , 64 + 36 ]
486
- let results : [ Int8 ] = [ 0 , 4 , 7 ] // another idea
486
+ let results : [ Int8 ] = [ 0 , 4 , 7 ]
487
487
let pitchSet = PitchSet ( pitches: openNotes. map { Pitch ( $0) } )
488
488
let resultSet = PitchSet ( pitches: results. map { Pitch ( $0) } )
489
489
XCTAssertEqual ( pitchSet. closedVoicing. transposedBassNoteTo ( octave: Note . MiddleCStandard. yamaha. firstOctaveOffset) , resultSet)
@@ -494,7 +494,7 @@ class ChordTests: XCTestCase {
494
494
let results : [ Int8 ] = [ 0 , 4 + 12 , 7 + 24 , 0 + 24 , 4 + 36 ] // another idea
495
495
let pitchSet = PitchSet ( pitches: openNotes. map { Pitch ( $0) } )
496
496
let resultSet = PitchSet ( pitches: results. map { Pitch ( $0) } )
497
- XCTAssertEqual ( pitchSet. transposedBassNoteTo ( octave: - 1 ) , resultSet)
497
+ XCTAssertEqual ( pitchSet. transposedBassNoteTo ( octave: Note . MiddleCStandard . yamaha . firstOctaveOffset ) , resultSet)
498
498
}
499
499
500
500
func testNewChords( ) {
@@ -546,8 +546,8 @@ class ChordTests: XCTestCase {
546
546
}
547
547
548
548
func testHalfDiminishedSeventhChords( ) {
549
- assertRankedChord ( [ 59 , 62 , 65 , 69 ] , expectedDescriptions: [ " Bø7 " ] )
550
- assertRankedChord ( [ 64 , 67 , 70 , 74 ] , expectedDescriptions: [ " Eø7 " ] )
549
+ assertRankedChord ( [ 59 , 62 , 65 , 69 ] , expectedDescriptions: [ " Bø7 " , " Dm6/B " ] )
550
+ assertRankedChord ( [ 64 , 67 , 70 , 74 ] , expectedDescriptions: [ " Eø7 " , " Gm6/E " ] )
551
551
}
552
552
553
553
func testDiminishedSeventhChords( ) {
@@ -563,8 +563,8 @@ class ChordTests: XCTestCase {
563
563
}
564
564
565
565
func testEleventhChords( ) {
566
- assertRankedChord ( [ 60 , 64 , 67 , 70 , 74 , 77 ] , expectedDescriptions: [ " C11 " , " Fmaj13sus2/C " ] )
567
- assertRankedChord ( [ 65 , 69 , 72 , 76 , 79 , 82 ] , expectedDescriptions: [ " Fmaj11 " ] )
566
+ assertRankedChord ( [ 60 , 64 , 67 , 70 , 74 , 77 ] , expectedDescriptions: [ " C11 " , " Fmaj13sus2/C " , " Fmaj13sus4/C " , " Gm13(add11)/C " ] )
567
+ assertRankedChord ( [ 65 , 69 , 72 , 76 , 79 , 82 ] , expectedDescriptions: [ " Fmaj11 " , " C13(add11)/F " ] )
568
568
}
569
569
570
570
func testThirteenthChords( ) {
@@ -593,13 +593,13 @@ class ChordTests: XCTestCase {
593
593
594
594
// MARK: - Suspended Chords
595
595
func testSus2Chords( ) {
596
- assertRankedChord ( [ 60 , 62 , 67 ] , expectedDescriptions: [ " Csus2 " ] )
597
- assertRankedChord ( [ 65 , 67 , 72 ] , expectedDescriptions: [ " Fsus2 " ] )
596
+ assertRankedChord ( [ 60 , 62 , 67 ] , expectedDescriptions: [ " Csus2 " , " Gsus4/C " ] )
597
+ assertRankedChord ( [ 65 , 67 , 72 ] , expectedDescriptions: [ " Fsus2 " , " Csus4/F " ] )
598
598
}
599
599
600
600
func testSus4Chords( ) {
601
- assertRankedChord ( [ 60 , 65 , 67 ] , expectedDescriptions: [ " Csus4 " ] )
602
- assertRankedChord ( [ 67 , 72 , 74 ] , expectedDescriptions: [ " Gsus4 " ] )
601
+ assertRankedChord ( [ 60 , 65 , 67 ] , expectedDescriptions: [ " Csus4 " , " Fsus2/C " ] )
602
+ assertRankedChord ( [ 67 , 72 , 74 ] , expectedDescriptions: [ " Gsus4 " , " Csus2/G " ] )
603
603
}
604
604
605
605
// MARK: - Add Chords
@@ -617,8 +617,8 @@ class ChordTests: XCTestCase {
617
617
}
618
618
619
619
func testSharpFiveChords( ) {
620
- assertRankedChord ( [ 60 , 64 , 68 ] , expectedDescriptions: [ " C⁺ " ] )
621
- assertRankedChord ( [ 65 , 69 , 73 ] , expectedDescriptions: [ " F⁺ " ] )
620
+ assertRankedChord ( [ 60 , 64 , 68 ] , expectedDescriptions: [ " C⁺ " , " A♭⁺/C " ] )
621
+ assertRankedChord ( [ 65 , 69 , 73 ] , expectedDescriptions: [ " F⁺ " , " D♭⁺/F " ] )
622
622
}
623
623
624
624
// MARK: - Inversions
@@ -642,12 +642,14 @@ class ChordTests: XCTestCase {
642
642
}
643
643
644
644
func testUncommonChords( ) {
645
- assertRankedChord ( [ 60 , 64 , 67 , 71 , 74 , 77 , 81 ] , expectedDescriptions: [ " Cmaj13 " ] )
646
- assertRankedChord ( [ 60 , 63 , 66 , 69 ] , expectedDescriptions: [ " CmMaj7 " ] )
645
+ assertRankedChord ( [ 60 , 64 , 67 , 71 , 74 , 77 , 81 ] , expectedDescriptions: [ " Cmaj13 " , " G13/C " , " Dm13/C " , " Am7(♭13)/C " , " Am11(♭13)/C " , " Fmaj13(♯11)/C " , " Em(♭13)(♭9)/C " , " Em7(♭9)(♭13)/C " , " Bø7(♭5)(♭9)(♭13)/C " ] )
646
+ assertRankedChord ( [ 60 , 63 , 66 , 69 ] , expectedDescriptions: [ " C°7 " , " A°7/C " , " F♯°7/C " , " D♯°7/C " ] )
647
+ assertRankedChord ( [ 60 , 63 , 67 , 71 ] , expectedDescriptions: [ " CmMaj7 " ] )
647
648
}
648
649
649
650
func testPolychordsAndAmbiguousChords( ) {
650
- assertRankedChord ( [ 65 , 69 , 72 , 76 , 79 ] , expectedDescriptions: [ " F6/9 " , " C/F " ] )
651
+ assertRankedChord ( [ 65 , 69 , 72 , 74 , 79 ] , expectedDescriptions: [ " F6/9 " , " G9sus4/F " , " G11sus2/F " , " Dm7(add11)/F " ] )
652
+ assertRankedChord ( [ 65 , 69 , 72 , 76 , 79 ] , expectedDescriptions: [ " Fmaj9 " , " Am7(add♭13)/F " ] )
651
653
}
652
654
653
655
}
0 commit comments