Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@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

NameInputsOutputDomain as coded
initTruePeaknonetwelve-sample f64 history
truePeakTickstate, inputmax(\x\
truePeakPhase12history, position, tapsmagnitude of one twelve-tap phaseposition indexes the newest sample
resetTruePeakstateclears history, position and sample count
TRUE_PEAK_PHASE_0 … TRUE_PEAK_PHASE_3, TRUE_PEAK_HISTORYconstantspublished 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.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Ports

  • In ininput · audio · mono
  • Out outoutput · audio · mono

One sample per truePeakTick call.

Dependencies

None: this node imports no other node.

Dependents

Used by