Skip to content

Commit

Permalink
improved ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianBoldt committed Jan 26, 2024
1 parent 2c099e2 commit 9db082c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Sources/Tonic/Chord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ extension Chord {
public func notes(octave: Int) -> [Note] {
var notes = noteClasses.map {
Note($0.letter, accidental: $0.accidental, octave: octave)
}.sorted()
}

for step in 0..<inversion {
let index = step % notes.count
notes[index].octave += 1
}

return notes
return notes.sorted()
}
}
8 changes: 4 additions & 4 deletions Tests/TonicTests/ChordTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ class ChordTests: XCTestCase {

// Assert
XCTAssertEqual(
pitches.sorted(),
expectedPitches.sorted(),
pitches,
expectedPitches,
"Pitches should match expected pitches for 1st inversion"
)
}
Expand Down Expand Up @@ -216,8 +216,8 @@ class ChordTests: XCTestCase {

// Assert
XCTAssertEqual(
notes.sorted(),
expectedNotes.sorted(),
notes,
expectedNotes,
"Notes should match expected notes for 1st inversion"
)
}
Expand Down

0 comments on commit 9db082c

Please sign in to comment.