DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::TruePeakDetector< T, MaxChannels > Class Template Reference

Per-channel 4x-oversampled inter-sample peak estimator. More...

#include <TruePeakDetector.h>

Public Member Functions

void reset () noexcept
 Clears all channel histories. Safe on the audio thread.
 
T processSample (T sample, int channel) noexcept
 Feeds one sample and returns the local true-peak estimate.
 
T getTailPeak (int channel) const noexcept
 Measures the zero-extended interpolation tail of one channel. Evaluates getTaps()-1 zero frames on a stack copy of that channel's state. Does not advance or clear live history. Call from the stream owner, not concurrently with processing/reset. Allocation-free and bounded work. Returns only the tail peak; combine with the maximum already observed.
 

Static Public Member Functions

static constexpr int getLatency () noexcept
 Group delay of the interpolation FIR in samples (per phase).
 
static constexpr int getTaps () noexcept
 Input samples one estimate is computed from (taps per phase).
 

Detailed Description

template<FloatType T, int MaxChannels = 16>
class dspark::TruePeakDetector< T, MaxChannels >

Per-channel 4x-oversampled inter-sample peak estimator.

Real-time safe: the polyphase coefficients are compile-time constants and processing is a fixed 48-multiply routine per sample. The reading is the maximum of the four official interpolation phases and the raw |sample| (the raw sample can only pull the estimate toward the true analog peak, never above it).

Template Parameters
TSample type (float or double).
MaxChannelsNumber of independent channel histories.

Definition at line 47 of file TruePeakDetector.h.

Member Function Documentation

◆ getLatency()

template<FloatType T, int MaxChannels = 16>
static constexpr int dspark::TruePeakDetector< T, MaxChannels >::getLatency ( )
inlinestaticconstexprnoexcept

Group delay of the interpolation FIR in samples (per phase).

Definition at line 96 of file TruePeakDetector.h.

◆ getTailPeak()

template<FloatType T, int MaxChannels = 16>
T dspark::TruePeakDetector< T, MaxChannels >::getTailPeak ( int  channel) const
inlinenoexcept

Measures the zero-extended interpolation tail of one channel. Evaluates getTaps()-1 zero frames on a stack copy of that channel's state. Does not advance or clear live history. Call from the stream owner, not concurrently with processing/reset. Allocation-free and bounded work. Returns only the tail peak; combine with the maximum already observed.

Definition at line 84 of file TruePeakDetector.h.

◆ getTaps()

template<FloatType T, int MaxChannels = 16>
static constexpr int dspark::TruePeakDetector< T, MaxChannels >::getTaps ( )
inlinestaticconstexprnoexcept

Input samples one estimate is computed from (taps per phase).

The reading returned for sample n was formed from x[n-getTaps()+1] .. x[n]. A caller that wants to change a reported peak has to change all of them: a gain applied to only part of that span does not scale the estimate by that gain.

Definition at line 106 of file TruePeakDetector.h.

◆ processSample()

template<FloatType T, int MaxChannels = 16>
T dspark::TruePeakDetector< T, MaxChannels >::processSample ( T  sample,
int  channel 
)
inlinenoexcept

Feeds one sample and returns the local true-peak estimate.

The result is the maximum of |sample| and the absolute values of the four official Annex 2 interpolation phases evaluated at this position (together they tile the 4x-oversampled reconstruction grid).

Parameters
sampleInput sample.
channelChannel index (0-based; clamped into range).
Returns
True-peak magnitude (>= |sample|).

Definition at line 68 of file TruePeakDetector.h.

◆ reset()

template<FloatType T, int MaxChannels = 16>
void dspark::TruePeakDetector< T, MaxChannels >::reset ( )
inlinenoexcept

Clears all channel histories. Safe on the audio thread.

Definition at line 51 of file TruePeakDetector.h.


The documentation for this class was generated from the following file: