Semitone Filterbank

audio_samples.pitch_filterbank holds the multirate semitone filterbank and the IIR time-frequency representation.

Multirate semitone filterbank and the IIR time-frequency representation.

audio_samples.pitch_filterbank.iirt(y, *, sr, win_length=2048, hop_length=None, center=True, tuning=0.0, pad_mode='constant', flayout='sos', res_type='soxr_hq', **kwargs)

The energy of each semitone band per frame.

Parameters:
  • y (array_like) – Signal (n,) or (channels, n), finite.

  • sr (int) – Sample rate in Hz.

  • win_length (int) – Frame length in samples. Default 2048.

  • hop_length (Optional[int]) – Samples between frames. Default win_length // 4.

  • center (bool) – Pad so that frames are centred. Default true.

  • tuning (float) – Deviation from A440 in fractions of a semitone.

  • pad_mode (str) – "constant", "edge", "reflect", "symmetric", "wrap".

  • flayout (str) – "sos" (default) or "ba".

  • res_type (str) – Resampler quality, as for AudioSamples.resample.

  • **kwargs – The filterbank’s parameters; see semitone_filterbank().

Returns:

(85, n_frames), with a leading channel axis for 2-D input, of y’s precision.

Return type:

numpy.ndarray

audio_samples.pitch_filterbank.mr_frequencies(tuning)

Centre frequencies and sample rates of the semitones from MIDI 24 to 108.

Parameters:

tuning (float) – Deviation from A440 in fractions of a semitone.

Returns:

Centre frequencies and sample rates in Hz, 85 of each.

Return type:

tuple[numpy.ndarray[float64], numpy.ndarray[float64]]

audio_samples.pitch_filterbank.semitone_filterbank(*, center_freqs=None, tuning=0.0, sample_rates=None, flayout='sos', **kwargs)

One band-pass filter per semitone, of minimum order for the specified response.

Parameters:
  • center_freqs (Optional[array_like]) – Centre frequencies in Hz; give together with sample_rates. Default: mr_frequencies().

  • tuning (float) – Used when center_freqs is not given.

  • sample_rates (Optional[array_like]) – The sample rate of each band in Hz.

  • flayout (str) – "sos" (default) or "ba". Polynomials lose precision at the orders these narrow filters reach.

  • **kwargs – Q (25), passband_ripple (1 dB), stopband_attenuation (50 dB), ftype ("ellip", "butter", "cheby1", "cheby2").

Returns:

One filter per band: an (n, 6) array of sections, or a (b, a) tuple; and the sample rates.

Return type:

tuple[list, numpy.ndarray[float64]]