Caution

You're reading the documentation for a development version. For the latest released version, please have a look at 0.10.2.

librosa.feature.fourier_tempogram

librosa.feature.fourier_tempogram(*, y=None, sr=22050, onset_envelope=None, hop_length=512, win_length=384, center=True, window='hann')[source]

Compute the Fourier tempogram: the short-time Fourier transform of the onset strength envelope. [1]

Parameters:
ynp.ndarray [shape=(…, n)] or None

Audio time series. Multi-channel is supported.

srnumber > 0 [scalar]

sampling rate of y

onset_envelopenp.ndarray [shape=(…, n)] or None

Optional pre-computed onset strength envelope as provided by librosa.onset.onset_strength. Multi-channel is supported.

hop_lengthint > 0

number of audio samples between successive onset measurements

win_lengthint > 0

length of the onset window (in frames/onset measurements) The default settings (384) corresponds to 384 * hop_length / sr ~= 8.9s.

centerbool

If True, onset windows are centered. If False, windows are left-aligned.

windowstring, function, number, tuple, or np.ndarray [shape=(win_length,)]

A window specification as in stft.

Returns:
tempogramnp.ndarray [shape=(…, win_length // 2 + 1, n)]

Complex short-time Fourier transform of the onset envelope.

Raises:
ParameterError

if neither y nor onset_envelope are provided

if win_length < 1

Examples

>>> # Compute local onset autocorrelation
>>> y, sr = librosa.load(librosa.ex('nutcracker'))
>>> hop_length = 512
>>> oenv = librosa.onset.onset_strength(y=y, sr=sr, hop_length=hop_length)
>>> tempogram = librosa.feature.fourier_tempogram(onset_envelope=oenv, sr=sr,
...                                               hop_length=hop_length)
>>> # Compute the auto-correlation tempogram, unnormalized to make comparison easier
>>> ac_tempogram = librosa.feature.tempogram(onset_envelope=oenv, sr=sr,
...                                          hop_length=hop_length, norm=None)
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots(nrows=3, sharex=True)
>>> ax[0].plot(librosa.times_like(oenv), oenv, label='Onset strength')
>>> ax[0].legend(frameon=True)
>>> ax[0].label_outer()
>>> librosa.display.specshow(np.abs(tempogram), sr=sr, hop_length=hop_length,
>>>                          x_axis='time', y_axis='fourier_tempo', cmap='magma',
...                          ax=ax[1])
>>> ax[1].set(title='Fourier tempogram')
>>> ax[1].label_outer()
>>> librosa.display.specshow(ac_tempogram, sr=sr, hop_length=hop_length,
>>>                          x_axis='time', y_axis='tempo', cmap='magma',
...                          ax=ax[2])
>>> ax[2].set(title='Autocorrelation tempogram')
../_images/librosa-feature-fourier_tempogram-1.png