Skip to main content

apply_equal_loudness

Function apply_equal_loudness 

Source
pub fn apply_equal_loudness(
    mag: &[f32],
    sample_rate: u32,
    out: &mut [f32],
) -> Result<usize, AudioError>
Expand description

Weight a magnitude spectrum mag by the A-weighting equal-loudness curve, writing mag.len() weighted magnitudes into out.

  • mag: N linear magnitudes for bins 0..N, spanning [0, fs/2].
  • sample_rate: source sample rate fs (Hz); must be non-zero.
  • out: at least N floats; receives mag[k] ยท w(f_k).

Returns the number of bins written (mag.len()), or AudioError::InvalidParameter for a zero sample rate, or AudioError::OutputBufferTooSmall if out is shorter than mag.