Caution
You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.9.1.
librosa.core.iirt¶
- librosa.core.iirt(y, sr=22050, win_length=2048, hop_length=None, center=True, tuning=0.0, pad_mode='reflect', flayout='sos', **kwargs)[source]¶
Time-frequency representation using IIR filters [1].
This function will return a time-frequency representation using a multirate filter bank consisting of IIR filters. First, y is resampled as needed according to the provided sample_rates. Then, a filterbank with with n band-pass filters is designed. The resampled input signals are processed by the filterbank as a whole. (
scipy.signal.filtfilt
resp. sosfiltfilt is used to make the phase linear.) The output of the filterbank is cut into frames. For each band, the short-time mean-square power (STMSP) is calculated by summing win_length subsequent filtered time samples.When called with the default set of parameters, it will generate the TF-representation as described in [1] (pitch filterbank):
85 filters with MIDI pitches [24, 108] as center_freqs.
each filter having a bandwith of one semitone.
- Parameters
- ynp.ndarray [shape=(n,)]
audio time series
- srnumber > 0 [scalar]
sampling rate of y
- win_lengthint > 0, <= n_fft
Window length.
- hop_lengthint > 0 [scalar]
Hop length, number samples between subsequent frames. If not supplied, defaults to win_length / 4.
- centerboolean
If True, the signal y is padded so that frame D[:, t] is centered at y[t * hop_length].
If False, then D[:, t] begins at y[t * hop_length]
- tuningfloat [scalar]
Tuning deviation from A440 in fractions of a bin.
- pad_modestring
If center=True, the padding mode to use at the edges of the signal. By default, this function uses reflection padding.
- flayoutstring
If sos (default), a series of second-order filters is used for filtering with
scipy.signal.sosfiltfilt
. Minimizes numerical precision errors for high-order filters, but is slower.If ba, the standard difference equation is used for filtering with
scipy.signal.filtfilt
. Can be unstable for high-order filters.
- kwargsadditional keyword arguments
Additional arguments for librosa.filters.semitone_filterbank() (e.g., could be used to provide another set of center_freqs and sample_rates).
- Returns
- bands_powernp.ndarray [shape=(n, t), dtype=dtype]
Short-time mean-square power for the input signal.
- Raises
- ParameterError
If flayout is not None, ba, or sos.
See also
Examples
>>> import matplotlib.pyplot as plt >>> y, sr = librosa.load(librosa.util.example_audio_file()) >>> D = np.abs(librosa.iirt(y)) >>> librosa.display.specshow(librosa.amplitude_to_db(D, ref=np.max), ... y_axis='cqt_hz', x_axis='time') >>> plt.title('Semitone spectrogram') >>> plt.colorbar(format='%+2.0f dB') >>> plt.tight_layout() >>> plt.show()