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.icqt¶
- librosa.icqt(C, *, sr=22050, hop_length=512, fmin=None, bins_per_octave=12, tuning=0.0, filter_scale=1, norm=1, sparsity=0.01, window='hann', scale=True, length=None, res_type='fft', dtype=None)[source]¶
Compute the inverse constant-Q transform.
Given a constant-Q transform representation
C
of an audio signaly
, this function produces an approximationy_hat
.- Parameters
- Cnp.ndarray, [shape=(…, n_bins, n_frames)]
Constant-Q representation as produced by
cqt
- srnumber > 0 [scalar]
sampling rate of the signal
- hop_lengthint > 0 [scalar]
number of samples between successive frames
- fminfloat > 0 [scalar]
Minimum frequency. Defaults to C1 ~= 32.70 Hz
- bins_per_octaveint > 0 [scalar]
Number of bins per octave
- tuningfloat [scalar]
Tuning offset in fractions of a bin.
The minimum frequency of the CQT will be modified to
fmin * 2**(tuning / bins_per_octave)
.- filter_scalefloat > 0 [scalar]
Filter scale factor. Small values (<1) use shorter windows for improved time resolution.
- norm{inf, -inf, 0, float > 0}
Type of norm to use for basis function normalization. See
librosa.util.normalize
.- sparsityfloat in [0, 1)
Sparsify the CQT basis by discarding up to
sparsity
fraction of the energy in each basis.Set
sparsity=0
to disable sparsification.- windowstr, tuple, number, or function
Window specification for the basis filters. See
filters.get_window
for details.- scalebool
If
True
, scale the CQT response by square-root the length of each channel’s filter. This is analogous tonorm='ortho'
in FFT.If
False
, do not scale the CQT. This is analogous tonorm=None
in FFT.- lengthint > 0, optional
If provided, the output
y
is zero-padded or clipped to exactlylength
samples.- res_typestring
Resampling mode. By default, this uses
'fft'
mode for high-quality reconstruction, but this may be slow depending on your signal duration. Seelibrosa.resample
for supported modes.- dtypenumeric type
Real numeric type for
y
. Default is inferred to match the numerical precision of the input CQT.
- Returns
- ynp.ndarray, [shape=(…, n_samples), dtype=np.float]
Audio time-series reconstructed from the CQT representation.
See also
Notes
This function caches at level 40.
Examples
Using default parameters
>>> y, sr = librosa.load(librosa.ex('trumpet')) >>> C = librosa.cqt(y=y, sr=sr) >>> y_hat = librosa.icqt(C=C, sr=sr)
Or with a different hop length and frequency resolution:
>>> hop_length = 256 >>> bins_per_octave = 12 * 3 >>> C = librosa.cqt(y=y, sr=sr, hop_length=256, n_bins=7*bins_per_octave, ... bins_per_octave=bins_per_octave) >>> y_hat = librosa.icqt(C=C, sr=sr, hop_length=hop_length, ... bins_per_octave=bins_per_octave)