@maruaudio/dsp/analysis/true-peak is the BS.1770-5 Annex 2 true-peak detector: a four-phase, 48-tap polyphase FIR (twelve taps per phase) that estimates the signal between samples at four times the rate. Each tick returns the largest of the input's own magnitude and the four phase magnitudes, so it is never below the sample peak. The coefficients are the published ones, stored as f64 constants. In floating point no 12.04 dB headroom attenuation is applied. The detector observes a signal and never delays or changes the audio.
Functions
| Name | Inputs | Output | Domain as coded |
|---|---|---|---|
initTruePeak | none | twelve-sample f64 history | |
truePeakTick | state, input | max(\ | x\ |
truePeakPhase12 | history, position, taps | magnitude of one twelve-tap phase | position indexes the newest sample |
resetTruePeak | state | clears history, position and sample count | |
TRUE_PEAK_PHASE_0 … TRUE_PEAK_PHASE_3, TRUE_PEAK_HISTORY | constants | published taps, 12 |
Lifecycle
initTruePeak() allocates the history → truePeakTick on every contiguous sample → resetTruePeak. Twelve samples fill the FIR history (samples counts up to 12). On Stop, flush twelve zeros to read the tail, without counting them as programme samples.
When to use it
Peak metering and ceiling checks where intersample overs matter, such as a mastering meter or a limiter's detector. @maru/analysis-programme-meter uses the detector and @maru/dynamics-lookahead-limiter uses the shared twelve-tap kernel with its own coefficients.
Limits
- Mono sample tick; one state per channel.
- At 44.1 kHz the estimate is at 176.4 kHz, below the Annex's minimum 192 kHz oversampled rate. Qualification is separate from algorithm identity.
- Non-finite input is not filtered here.
- Twelve-tap loops over prepared storage; no allocation after init.