Skip to main content

mel_bands

Function mel_bands 

Source
pub fn mel_bands(
    power_spectrum: &[f32],
    bank_weights: &[f32],
    n_mel: usize,
    out: &mut [f32],
) -> Result<(), AudioError>
Expand description

Apply a n_mel × n_fft_bins bank (row-major, from super::mel_bank::build_mel_bank) to one power_spectrum frame.

For each filter row m, computes the dot product Σ_b bank[m,b] * power[b] and writes it to out[m]. This is a pure matrix-vector apply: no allocation, no logarithm (callers wanting log-mel take ln themselves, or use super::mfcc::mfcc). The number of FFT bins is inferred from bank_weights.len() / n_mel, and power_spectrum must cover at least that many.

Returns AudioError::InvalidParameter if n_mel == 0 or the bank length is not a positive multiple of n_mel, and AudioError::OutputBufferTooSmall if out is shorter than n_mel or power_spectrum is shorter than the bank width.