From fed4902cdb155bd0efb0295a071f3fa6fa16de96 Mon Sep 17 00:00:00 2001 From: Aurelius Prochazka Date: Thu, 11 Apr 2024 10:51:16 -0700 Subject: [PATCH] Added 7sus2, a little cleanup on 7sus4 --- Sources/Tonic/ChordType.swift | 14 ++++++++++---- Tests/TonicTests/ChordTests.swift | 11 +++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Sources/Tonic/ChordType.swift b/Sources/Tonic/ChordType.swift index a6bfee1..e307843 100644 --- a/Sources/Tonic/ChordType.swift +++ b/Sources/Tonic/ChordType.swift @@ -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 @@ -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] @@ -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" @@ -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" diff --git a/Tests/TonicTests/ChordTests.swift b/Tests/TonicTests/ChordTests.swift index 8935e95..421415d 100644 --- a/Tests/TonicTests/ChordTests.swift +++ b/Tests/TonicTests/ChordTests.swift @@ -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() {