Skip to content

Commit

Permalink
Added 7sus4
Browse files Browse the repository at this point in the history
  • Loading branch information
aure committed Apr 11, 2024
1 parent 255aa20 commit dbb6668
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Sources/Tonic/ChordType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion Tests/TonicTests/ChordTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ 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) } )
let c7 = Chord.getRankedChords(from: pitchSet)
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) } )
Expand Down

0 comments on commit dbb6668

Please sign in to comment.