Skip to content

Commit

Permalink
Added 7sus2, a little cleanup on 7sus4
Browse files Browse the repository at this point in the history
  • Loading branch information
aure committed Apr 11, 2024
1 parent dbb6668 commit fed4902
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
14 changes: 10 additions & 4 deletions Sources/Tonic/ChordType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ public enum ChordType: String, CaseIterable, Codable {
case dominantSeventh

/// Dominant Seventh Suspendend Fourth: Perfect Fourth, Perfect Fifth, Minor Seventh
case dominantSeventhSus4
case dominantSeventhSuspendedFourth

/// Dominant Seventh Suspendend Second: Major Second, Perfect Fifth, Minor Seventh
case dominantSeventhSuspendedSecond

/// Major Seventh: Major Third, Perfect Fifth, Major Seventh
case majorSeventh
Expand Down Expand Up @@ -154,7 +157,8 @@ public enum ChordType: String, CaseIterable, Codable {
case .halfDiminishedSeventh: return [.m3, .d5, .m7]
case .diminishedSeventh: return [.m3, .d5, .d7]
case .dominantSeventh: return [.M3, .P5, .m7]
case .dominantSeventhSus4: return [.P4, .P5, .m7]
case .dominantSeventhSuspendedFourth: return [.P4, .P5, .m7]
case .dominantSeventhSuspendedSecond: return [.M2, .P5, .m7]
case .majorSeventh: return [.M3, .P5, .M7]
case .minorSeventh: return [.m3, .P5, .m7]
case .minorMajorSeventh: return [.m3, .P5, .M7]
Expand Down Expand Up @@ -207,7 +211,8 @@ extension ChordType: CustomStringConvertible {
case .halfDiminishedSeventh: return "ø7"
case .diminishedSeventh: return "°7"
case .dominantSeventh: return "7"
case .dominantSeventhSus4: return "7sus4"
case .dominantSeventhSuspendedFourth: return "7sus4"
case .dominantSeventhSuspendedSecond: return "7sus2"
case .majorSeventh: return "maj7"
case .minorSeventh: return "m7"
case .minorMajorSeventh: return "mMaj7"
Expand Down Expand Up @@ -260,7 +265,8 @@ extension ChordType: CustomStringConvertible {
case .halfDiminishedSeventh: return "Ø7"
case .diminishedSeventh: return "º7"
case .dominantSeventh: return "7"
case .dominantSeventhSus4: return "7sus4"
case .dominantSeventhSuspendedFourth: return "7sus4"
case .dominantSeventhSuspendedSecond: return "7sus2"
case .majorSeventh: return "^7"
case .minorSeventh: return "m7"
case .minorMajorSeventh: return "m^7"
Expand Down
11 changes: 9 additions & 2 deletions Tests/TonicTests/ChordTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ class ChordTests: XCTestCase {
func test7sus4() {
let notes: [Int8] = [60, 65, 67, 70]
let pitchSet = PitchSet(pitches: notes.map { Pitch($0) } )
let c7 = Chord.getRankedChords(from: pitchSet)
XCTAssertEqual(c7.map { $0.description }, ["C7sus4"])
let c7sus4 = Chord.getRankedChords(from: pitchSet)
XCTAssertEqual(c7sus4.map { $0.description }, ["C7sus4"])
}

func test7sus2() {
let notes: [Int8] = [60, 62, 67, 70]
let pitchSet = PitchSet(pitches: notes.map { Pitch($0) } )
let c7sus2 = Chord.getRankedChords(from: pitchSet)
XCTAssertEqual(c7sus2.map { $0.description }, ["C7sus2"])
}

func testAugmentedDiminishededChordsPreferNoInversions() {
Expand Down

0 comments on commit fed4902

Please sign in to comment.