From dbb666870f4ede15b9bf9ded28d844e943e57c0f Mon Sep 17 00:00:00 2001 From: Aurelius Prochazka Date: Thu, 11 Apr 2024 10:43:49 -0700 Subject: [PATCH] Added 7sus4 --- Sources/Tonic/ChordType.swift | 6 ++++++ Tests/TonicTests/ChordTests.swift | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Sources/Tonic/ChordType.swift b/Sources/Tonic/ChordType.swift index f13de28..a6bfee1 100644 --- a/Sources/Tonic/ChordType.swift +++ b/Sources/Tonic/ChordType.swift @@ -41,6 +41,9 @@ public enum ChordType: String, CaseIterable, Codable { /// Dominant Seventh: Major Third, Perfect Fifth, Minor Seventh case dominantSeventh + /// Dominant Seventh Suspendend Fourth: Perfect Fourth, Perfect Fifth, Minor Seventh + case dominantSeventhSus4 + /// Major Seventh: Major Third, Perfect Fifth, Major Seventh case majorSeventh @@ -151,6 +154,7 @@ 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 .majorSeventh: return [.M3, .P5, .M7] case .minorSeventh: return [.m3, .P5, .m7] case .minorMajorSeventh: return [.m3, .P5, .M7] @@ -203,6 +207,7 @@ extension ChordType: CustomStringConvertible { case .halfDiminishedSeventh: return "ø7" case .diminishedSeventh: return "°7" case .dominantSeventh: return "7" + case .dominantSeventhSus4: return "7sus4" case .majorSeventh: return "maj7" case .minorSeventh: return "m7" case .minorMajorSeventh: return "mMaj7" @@ -255,6 +260,7 @@ extension ChordType: CustomStringConvertible { case .halfDiminishedSeventh: return "Ø7" case .diminishedSeventh: return "º7" case .dominantSeventh: return "7" + case .dominantSeventhSus4: return "7sus4" 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 6d05e9d..8935e95 100644 --- a/Tests/TonicTests/ChordTests.swift +++ b/Tests/TonicTests/ChordTests.swift @@ -32,7 +32,7 @@ class ChordTests: XCTestCase { XCTAssertEqual(cb5.map { $0.description }, ["C♭5"]) } - func testC7() { + func test7() { XCTAssertEqual(Chord(.C, type: .dominantSeventh).description, "C7") let notes: [Int8] = [60, 67, 70, 76] let pitchSet = PitchSet(pitches: notes.map { Pitch($0) } ) @@ -40,6 +40,13 @@ class ChordTests: XCTestCase { XCTAssertEqual(c7.map { $0.description }, ["C7"]) } + 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"]) + } + func testAugmentedDiminishededChordsPreferNoInversions() { let notes: [Int8] = [60, 64, 68] let pitchSet = PitchSet(pitches: notes.map { Pitch($0) } )