• Stars
    star
    611
  • Rank 73,401 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A framework for composing and transforming music in Swift

MusicKit

MusicKit is a framework and DSL for creating, analyzing, and transforming music in Swift.

Examples

Functional harmony

let C5 = Pitch(midi: 72)
let neapolitan = Major.bII
print(neapolitan(C5))               // [Cβ™―5, Eβ™―5, Gβ™―5]
let G4 = Chroma.G*4
let plagalCadence = [Major.IV, Major.I]
print(plagalCadence * G4)           // [[C5, E5, G5], [G4, B4, D5]]
let V7ofV = HarmonicFunction.create(Scale.Major, degree: 5, chord: Major.V7)
print(V7ofV(C5))                    // [D6, Fβ™―6, A6, C7]

Chord recognition

let pitchSet: PitchSet = [Chroma.B*0, Chroma.Cs*2, Chroma.F*3, Chroma.G*4]
print(Chord.name(pitchSet))        // G7β™­5/B
let descriptor = Chord.descriptor(pitchSet)
print(descriptor)                  // root: G, quality: 7β™­5, bass: B

MIDI I/O

let midi = MIDI(name: "WholetoneClusters")
midi.noteHandler = { messages in
    if let first = messages.first {
        midi.send([first, first.transpose(2), first.transpose(3)])
    }
}

Framework Overview