librosa.hz_to_octs

librosa.hz_to_octs(frequencies, *, tuning=0.0, bins_per_octave=12)[source]

Convert frequencies (Hz) to (fractional) octave numbers.

Parameters:
frequenciesnumber >0 or np.ndarray [shape=(n,)] or float

scalar or vector of frequencies

tuningfloat

Tuning deviation from A440 in (fractional) bins per octave.

bins_per_octaveint > 0

Number of bins per octave.

Returns:
octavesnumber or np.ndarray [shape=(n,)]

octave number for each frequency

See also

octs_to_hz

Examples

>>> librosa.hz_to_octs(440.0)
4.
>>> librosa.hz_to_octs([32, 64, 128, 256])
array([ 0.219,  1.219,  2.219,  3.219])