librosa.filters.wavelet_lengths
- librosa.filters.wavelet_lengths(*, freqs, sr=22050, window='hann', filter_scale=1, gamma=0, alpha=None)[source]
Return length of each filter in a wavelet basis.
- Parameters:
- freqsnp.ndarray (positive)
Center frequencies of the filters (in Hz). Must be in ascending order.
- srnumber > 0 [scalar]
Audio sampling rate
- windowstr or callable
Window function to use on filters
- filter_scalefloat > 0 [scalar]
Resolution of filter windows. Larger values use longer windows.
- gammanumber >= 0 [scalar, optional]
Bandwidth offset for determining filter lengths, as used in Variable-Q transforms.
Bandwidth for the k’th filter is determined by:
B[k] = alpha[k] * freqs[k] + gamma
alpha[k]
is twice the relative difference betweenfreqs[k+1]
andfreqs[k-1]
:alpha[k] = (freqs[k+1]-freqs[k-1]) / (freqs[k+1]+freqs[k-1])
If
freqs
follows a geometric progression (as in CQT and VQT), the vectoralpha
is constant and such that:(1 + alpha) * freqs[k-1] = (1 - alpha) * freqs[k+1]
Furthermore, if
gamma=0
(default),alpha
is such that even-k
and odd-k
filters are interleaved:freqs[k-1] + B[k-1] = freqs[k+1] - B[k+1]
If
gamma=None
is specified, thengamma
is computed such that each filter has bandwidth proportional to the equivalent rectangular bandwidth (ERB) at frequencyfreqs[k]
:gamma[k] = 24.7 * alpha[k] / 0.108
as derived by [1].
- alphanumber > 0 [optional]
If only one frequency is provided (
len(freqs)==1
), then filter bandwidth cannot be computed. In that case, thealpha
parameter described above can be explicitly specified here.If two or more frequencies are provided, this parameter is ignored.
- Returns:
- lengthsnp.ndarray
The length of each filter.
- f_cutofffloat
The lowest frequency at which all filters’ main lobes have decayed by at least 3dB.
This second output serves in cqt and vqt to ensure that all wavelet bands remain below the Nyquist frequency.
- Raises:
- ParameterError
If
filter_scale
is not strictly positiveIf
gamma
is a negative numberIf any frequencies are <= 0
If the frequency array is not sorted in ascending order
Notes
This function caches at level 10.