librosa.feature.logfsgram¶
- librosa.feature.logfsgram(y=None, sr=22050, S=None, n_fft=2048, hop_length=512, **kwargs)¶
Compute a log-frequency spectrogram using a fixed-window STFT.
Warning
Deprecated in librosa 0.4 Functionality is superseded by librosa.core.pseudo_cqt
Parameters: y : np.ndarray [shape=(n,)] or None
audio time series
sr : number > 0 [scalar]
audio sampling rate of y
S : np.ndarray [shape=(d, t)] or None
(optional) power spectrogram
n_fft : int > 0 [scalar]
FFT window size
hop_length : int > 0 [scalar]
hop length for STFT. See librosa.core.stft for details.
bins_per_octave : int > 0 [scalar]
Number of bins per octave. Defaults to 12.
tuning : float in [-0.5, 0.5) [scalar]
Deviation (in fractions of a bin) from A440 tuning.
If not provided, it will be automatically estimated.
kwargs : additional keyword arguments
Returns: P : np.ndarray [shape=(n_pitches, t)]
P[f, t] contains the energy at pitch bin f, frame t.
Examples
From time-series input
>>> y, sr = librosa.load(librosa.util.example_audio_file()) >>> L = librosa.feature.logfsgram(y=y, sr=sr) >>> L array([[ 1.309e-02, 1.228e+00, ..., 3.785e-08, 7.624e-09], [ 1.630e-24, 1.528e-22, ..., 4.710e-30, 9.488e-31], ..., [ 2.617e-05, 3.807e-04, ..., 6.387e-08, 6.000e-08], [ 3.214e-05, 3.814e-04, ..., 7.599e-08, 6.046e-08]])
Plot the pseudo CQT
>>> import matplotlib.pyplot as plt >>> plt.figure() >>> librosa.display.specshow(librosa.logamplitude(L, ... ref_power=np.max), ... y_axis='cqt_hz', x_axis='time') >>> plt.title('Log-frequency power spectrogram') >>> plt.colorbar(format='%+2.0f dB') >>> plt.tight_layout()