Skip to content

Instantly share code, notes, and snippets.

@tuppaware
Created July 16, 2020 03:52
Show Gist options
  • Save tuppaware/d620baab69a2f5d5ac80bfeef6c3a84b to your computer and use it in GitHub Desktop.
Save tuppaware/d620baab69a2f5d5ac80bfeef6c3a84b to your computer and use it in GitHub Desktop.
Swift Midi Note Number to Midi Key (as a String)
func midiNumberToKey(midiNote: MIDINoteNumber)-> String {
let keys = ["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];
let note = Int(midiNote)
return keys[note % 12] + " \(Int(floor(note / 12)))"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment