code: def midi2str(midi_number, sharp=True):
    
    if isinf(midi_number) or isnan(midi_number):
      return "?"
    num = midi_number - (MIDI_A4 - 4 * 12 - 9)
    note = (num + .5) % 12 - .5
    rnote = int(round(note))
    error = note - rnote
    octave = str(int(round((num - note) / 12.)))
    if sharp:
      names = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
    else:
      names = ["C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"]
    names = names[rnote] + octave
    if abs(error) < 1e-4:
      return names
    else:
      err_sig = "+" if error > 0 else "-"
      err_str = err_sig + str(round(100 * abs(error), 2)) + "%"
      return names + err_str
docs: Given a MIDI pitch number, returns its note string name (e.g. "C3").