Expand description
Equal-loudness contour weighting applied to a magnitude spectrum.
Human hearing is not flat: energy near 2–4 kHz is perceived as much louder than the same energy at 50 Hz or 15 kHz. This module weights a linear magnitude spectrum by an A-weighting curve — the standard analytic approximation of the (inverted) 40-phon ISO 226 equal-loudness contour — so that downstream loudness / salience measures reflect perception rather than raw physical energy.
The curve is normalised to unity (0 dB) gain at 1 kHz. It is caller-buffered
and allocation-free: bin k of an N-bin spectrum spanning [0, Nyquist]
is treated as frequency k · (fs/2) / (N-1).
Functions§
- apply_
equal_ loudness - Weight a magnitude spectrum
magby the A-weighting equal-loudness curve, writingmag.len()weighted magnitudes intoout.