librosa.core.midi_to_note

librosa.core.midi_to_note(midi, octave=True, cents=False)[source]

Convert one or more MIDI numbers to note strings.

MIDI numbers will be rounded to the nearest integer.

Notes will be of the format ‘C0’, ‘C#0’, ‘D0’, …

Parameters:
midi : int or iterable of int

Midi numbers to convert.

octave: bool

If True, include the octave number

cents: bool

If true, cent markers will be appended for fractional notes. Eg, midi_to_note(69.3, cents=True) == A4+03

Returns:
notes : str or iterable of str

Strings describing each midi note.

Raises:
ParameterError

if cents is True and octave is False

Examples

>>> librosa.midi_to_note(0)
'C-1'
>>> librosa.midi_to_note(37)
'C#2'
>>> librosa.midi_to_note(-2)
'A#-2'
>>> librosa.midi_to_note(104.7)
'A7'
>>> librosa.midi_to_note(104.7, cents=True)
'A7-30'
>>> librosa.midi_to_note(list(range(12, 24)))
['C0', 'C#0', 'D0', 'D#0', 'E0', 'F0', 'F#0', 'G0', 'G#0', 'A0', 'A#0', 'B0']