librosa.A4_to_tuning

librosa.A4_to_tuning(A4, bins_per_octave=12)[source]

Convert a reference pitch frequency (e.g., A4=435) to a tuning estimation, in fractions of a bin per octave.

This is useful for determining the tuning deviation relative to A440 of a given frequency, assuming equal temperament. By default, 12 bins per octave are used.

This method is the inverse of tuning_to_A4.

Parameters
A4: float or np.ndarray [shape=(n,), dtype=float]

Reference frequency(s) corresponding to A4.

bins_per_octaveint > 0

Number of bins per octave.

Returns
tuningfloat or np.ndarray [shape=(n,), dtype=float]

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

See also

tuning_to_A4

Examples

The base case of this method in which A440 yields 0 tuning offset from itself.

>>> librosa.A4_to_tuning(440.0)
0.

Convert a non-A440 frequency to a tuning offset relative to A440 using the default of 12 bins per octave.

>>> librosa.A4_to_tuning(432.0)
-0.318

Convert two reference pitch frequencies to corresponding tuning estimations at once, but using 24 bins per octave.

>>> librosa.A4_to_tuning([440.0, 444.0], bins_per_octave=24)
array([   0.,   0.313   ])