You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.10.2.


librosa.estimate_tuning(y=None, sr=22050, S=None, n_fft=2048, resolution=0.01, bins_per_octave=12, **kwargs)[source]

Estimate the tuning of an audio time series or spectrogram input.

y: np.ndarray [shape=(n,)] or None

audio signal

srnumber > 0 [scalar]

audio sampling rate of y

S: np.ndarray [shape=(d, t)] or None

magnitude or power spectrogram

n_fftint > 0 [scalar] or None

number of FFT bins to use, if y is provided.

resolutionfloat in (0, 1)

Resolution of the tuning as a fraction of a bin. 0.01 corresponds to measurements in cents.

bins_per_octaveint > 0 [scalar]

How many frequency bins per octave

kwargsadditional keyword arguments

Additional arguments passed to piptrack

tuning: float in [-0.5, 0.5)

estimated tuning deviation (fractions of a bin)

See also


Pitch tracking by parabolic interpolation


With time-series input

>>> y, sr = librosa.load(librosa.ex('trumpet'))
>>> librosa.estimate_tuning(y=y, sr=sr)

In tenths of a cent

>>> librosa.estimate_tuning(y=y, sr=sr, resolution=1e-3)

Using spectrogram input

>>> S = np.abs(librosa.stft(y))
>>> librosa.estimate_tuning(S=S, sr=sr)

Using pass-through arguments to librosa.piptrack

>>> librosa.estimate_tuning(y=y, sr=sr, n_fft=8192,
...                         fmax=librosa.note_to_hz('G#9'))