Filter banks & windows
The filters namespace holds the reusable building blocks that the feature layer
composes: the mel filterbank, the chroma filterbank, and the analysis windows.
If feature is the “what,” filters is the “how” — the matrices and window
functions you can pull out and apply yourself when building a custom pipeline.
Key functions
Section titled “Key functions”filters.mel_filterbank(sr?, n_fft?, n_mels?, fmin?, fmax?, norm?, htk?)— the mel projection matrix: continuous Slaney triangular ramps over the FFT frequency grid with Slaney area normalization (HTK scale and other norms optional). Arguments are positional, defaulting to(22050, 2048, 128, 0, null, 'slaney', false). Multiply it against a power spectrogram to get a mel spectrogram.filters.chroma({ sr, n_fft })— the chroma filterbank: Gaussian pitch-class bumps with octave weighting and tuning.feature.chroma_stftis a matmul of this against the energy spectrum.filters.get_window(type, n)— a window function (hann,hamming,blackman). Periodic by convention (fftbins=True), matching scipy — the correct choice for spectral analysis.
Example
Section titled “Example”import { filters } from 'pleco-xa'
// build the mel matrix once, reuse across frames — positional args: (sr, n_fft, n_mels)const melFb = filters.mel_filterbank(22050, 2048, 128)
// a periodic Hann window for your own STFT framingconst win = filters.get_window('hann', 2048)mel_filterbanktakes positional arguments, unlike the options-object style of thefeaturenamespace. Passing an options object (mel_filterbank({ sr: 22050, ... })) does not throw — it silently produces a garbage matrix. Use the positional form shown above.- Windows are periodic (
2π·i / n), not symmetric (/(n-1)). This is the scipyfftbins=Trueconvention; the symmetric form skews every spectrogram bin. - The mel filterbank defaults to the Slaney scale with area normalization.
Pass
htk: truefor the HTK scale. - These are the same filterbanks
feature.melspectrogramandfeature.chroma_stftuse internally; exposing them lets you build custom feature stacks without re-deriving the matrices.
See the API reference for full signatures.