Created
July 16, 2020 03:52
-
-
Save tuppaware/d620baab69a2f5d5ac80bfeef6c3a84b to your computer and use it in GitHub Desktop.
Swift Midi Note Number to Midi Key (as a String)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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