Skip to content

Commit

Permalink
Added 9sus4
Browse files Browse the repository at this point in the history
  • Loading branch information
aure committed Apr 11, 2024
1 parent fed4902 commit f93a8b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/Tonic/ChordType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public enum ChordType: String, CaseIterable, Codable {
/// Dominant Ninth: Major Third, Perfect Fifth, Minor Seventh, Major Ninth
case dominantNinth

/// Dominant Ninth Suspended Fourth: Perfect Fourth, Perfect Fifth, Major Ninth (Major Second)
case dominantNinthSuspendedFourth

/// Flat Ninth: Major Third, Perfect Fifth, Minor Seventh, Minor Ninth
case flatNinth

Expand Down Expand Up @@ -164,6 +167,7 @@ public enum ChordType: String, CaseIterable, Codable {
case .minorMajorSeventh: return [.m3, .P5, .M7]
case .halfDiminishedNinth: return [.m3, .d5, .m7, .m9]
case .dominantNinth: return [.M3, .P5, .m7, .M9]
case .dominantNinthSuspendedFourth: return [.P4, .P5, .M9]
case .flatNinth: return [.M3, .P5, .m7, .m9]
case .sharpNinth: return [.M3, .P5, .m7, .A9]
case .majorNinth: return [.M3, .P5, .M7, .M9]
Expand Down Expand Up @@ -218,6 +222,7 @@ extension ChordType: CustomStringConvertible {
case .minorMajorSeventh: return "mMaj7"
case .halfDiminishedNinth: return "ø9"
case .dominantNinth: return "9"
case .dominantNinthSuspendedFourth: return "9sus4"
case .flatNinth: return "7♭9"
case .sharpNinth: return "7♯9"
case .majorNinth: return "maj9"
Expand Down Expand Up @@ -272,6 +277,7 @@ extension ChordType: CustomStringConvertible {
case .minorMajorSeventh: return "m^7"
case .halfDiminishedNinth: return "Ø9"
case .dominantNinth: return "9"
case .dominantNinthSuspendedFourth: return "9sus4"
case .flatNinth: return "7b9"
case .sharpNinth: return "7#9"
case .majorNinth: return "^9"
Expand Down
7 changes: 7 additions & 0 deletions Tests/TonicTests/ChordTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class ChordTests: XCTestCase {
XCTAssertEqual(c7sus2.map { $0.description }, ["C7sus2"])
}

func test9sus4() {
let notes: [Int8] = [60, 65, 67, 74]
let pitchSet = PitchSet(pitches: notes.map { Pitch($0) } )
let c9sus4 = Chord.getRankedChords(from: pitchSet)
XCTAssertEqual(c9sus4.map { $0.description }, ["C9sus4", "G7sus4"])
}

func testAugmentedDiminishededChordsPreferNoInversions() {
let notes: [Int8] = [60, 64, 68]
let pitchSet = PitchSet(pitches: notes.map { Pitch($0) } )
Expand Down

0 comments on commit f93a8b5

Please sign in to comment.