Skip to content

Why this exists

Loudness metering is deceptively hard to get right. The ITU-R BS.1770 recommendation defines a handful of numbers (integrated loudness, true peak, loudness range) but the path from a PCM buffer to those numbers is full of spec details that change the result by a dB or more:

  • K-weighting is defined for a 48 kHz measurement grid. Feed it 44.1 kHz audio directly and the high-shelf + high-pass biquad coefficients are wrong.
  • Gating is relative: the absolute gate is -70 LKFS, the relative gate is integrated - 10 LU, and both are computed on 400 ms overlapping blocks.
  • True peak is defined as the peak of the reconstructed (interpolated) waveform, not the sample peak, and the standard says you should oversample by at least 192 kHz.
  • Real signals are not full-scale sines. Integrated loudness of a streaming master typically sits between -16 and -8 LUFS, so small implementation errors that are invisible in a sine test become audible mismatches across platforms.

dsp-audio-metrics exists to give you one small, auditable implementation that does all of this with zero dependencies, and pins every number to the spec with tests:

CheckValue pinned by test
Full-scale 1 kHz sine-3.01 LUFS
Halving amplitudeexactly -6.02 LU
True peak of full-scale sine0 dBTP
Silence-Infinity, LRA NaN
44.1 kHz vs 48 kHz inputagree within 0.1

Relationship to the Python package

The same engine and test suite exist as a Python package, dsp-audio-metrics on PyPI, which implements the reference scipy-based algorithm. The JavaScript port mirrors its behaviour (and its tests) exactly, so the two ecosystems produce identical measurements.