Convert an integer value into its MIDI note name

var
   notesInOctave : string array

function NoteNumberToString(n : integer) returns string
   var octaveNumber : integer
       semitone : integer

   octaveNumber = (n / 12) - 2 // so that 60 will be C3
   semitone = n % 12
   
   result = notesInOctave[semitone] + octaveNumber
   
end


initialization
   // Initialize the names of each notes in an octave
   notesInOctave = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
end

Be aware that this function does not validate its input. It assumes that the incoming value is legitimate, between 0 and 127