diff --git a/Sources/Tonic/Chord.swift b/Sources/Tonic/Chord.swift index 6cc397d..34d8e05 100644 --- a/Sources/Tonic/Chord.swift +++ b/Sources/Tonic/Chord.swift @@ -154,13 +154,40 @@ extension Chord { /// - Parameter octave: initial octave of the chord for inversion 0 /// - Returns: All notes in that chord public func notes(octave: Int) -> [Note] { - var notes = noteClasses.map { - Note($0.letter, accidental: $0.accidental, octave: octave) + // This array will store all the notes with the correct octaves + var notes: [Note] = [] + // Convert the root note class to a note object + let rootNote = Note(root.letter, accidental: root.accidental, octave: octave) + // append the note to the array of our notes + notes.append(rootNote) + + // Iterate over all intervals + for interval in self.type.intervals { + // Create the next note by using the shiftup function + if let shifted = rootNote.shiftUp(interval) { + notes.append(shifted) + } } + // Stores all shifted notes + var shiftedNotes: [Note] = [] + + // Iterate over all inversion steps for step in 0..