Caution

You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.10.2.

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 between freqs[k+1] and freqs[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 vector alpha 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, then gamma is computed such that each filter has bandwidth proportional to the equivalent rectangular bandwidth (ERB) at frequency freqs[k]:

gamma[k] = 24.7 * alpha[k] / 0.108

as derived by [1].

alphanumber > 0 [optional]

Optional pre-computed relative bandwidth parameter. Note that this must be provided if len(freqs)==1 because bandwidth cannot be inferred from a single frequency. Otherwise, if left unspecified, it will be automatically derived by the rules specified above.

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 positive

  • If gamma is a negative number

  • If any frequencies are <= 0

  • If the frequency array is not sorted in ascending order

Notes

This function caches at level 10.