music.hz_to_midi

music.hz_to_midi(hertz_value)[source]

Converts a frequency in Hertz to a MIDI note number.

This function takes a frequency value in Hertz as input and returns the corresponding MIDI note number.

Parameters:
hertz_valuefloat

The frequency value in Hertz to be converted.

Returns:
numpy.float64

The MIDI note number corresponding to the input frequency value. A frequency of zero or below, which has no pitch, is taken as the smallest positive float, a pitch near -680, far below hearing: an array of frequencies with silent frames at 0 Hz converts without numpy’s warning about a logarithm of zero.

Parameters:

hertz_value (float)

Return type:

float64

Examples

>>> float(hz_to_midi(440))
69.0
>>> float(hz_to_midi(880))
81.0