|
DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
|
Running-maximum reading of the band-limited reconstruction peak, for meters. More...
#include <TruePeakDetector.h>
Classes | |
| struct | Channel |
| History of one channel (each stage's kernel span plus one chunk). More... | |
Public Member Functions | |
| TruePeakAnalyzer () noexcept | |
| Designs the three interpolation stages. | |
| T | processMax (Channel &channel, const T *x, int n, T atLeast) noexcept |
| Appends samples to a channel and returns the largest finite reading among the 8x grid points they complete (0 if none). | |
| void | process (Channel &channel, const T *x, int n, T *peak, T *annex2=nullptr) noexcept |
| Appends samples to a channel and raises each peak[i] to the reading of the 8x grid points x[i] completes. | |
| T | getTailPeak (const Channel &channel) noexcept |
| Peak of the zero-extended tail of a finite programme. | |
Static Public Member Functions | |
| static constexpr int | getDelay () noexcept |
| Input samples one reading reaches back: the newest 8x grid point a call reads lies this many samples before the newest input sample, at most. | |
Static Public Attributes | |
| static constexpr int | kTaps = 512 |
| Taps of the first (interval midpoint) stage. | |
| static constexpr int | kChunk = 128 |
| Most samples one processMax() call takes. | |
Running-maximum reading of the band-limited reconstruction peak, for meters.
The BS.1770 Annex 2 procedure (over-sampling, low-pass interpolation, absolute value) carried to 8x in three stages: a 512-tap Kaiser-windowed sinc (beta 7) reads the midpoint of every sample interval, a 16-tap one (beta 9) the midpoints of that 2x stream and an 8-tap one (beta 9) the midpoints of the 4x stream (the 2x stream fills only the lower half of its band and the 4x stream the lower quarter, so short kernels are exact there). The vertex of the parabola through every local maximum of the 8x grid refines the crest. The long first stage is what reads content near Nyquist: the transition band of an interpolator is as wide as its kernel is short, and a tone inside it is reconstructed with the wrong phase between samples, so a kernel that reaches 32 samples (TruePeakEstimator) misplaces every crest a tone above 0.45 fs builds where it starts or stops.
Measured against the exact reconstruction sum of the zero-extended signal (TruePeakEstimator in brackets): steady sines up to 0.49 fs read within 0.004 dB (0.002); tones that start abruptly within 0.01 dB up to 0.45 fs (-0.22 / +0.06), -0.09 / +0.05 dB up to 0.485 fs (-0.82 / +0.75) and -0.21 / +0.08 dB at 0.49 fs (-1.2 / +0.11); noise band-limited to 0.45 fs within 0.003 dB (0.02); white noise -0.19 / +0.13 dB (-0.55 / +0.47); noise with all its energy above 0.40 fs -0.27 / +0.20 dB (-0.98 / +0.63). What is left belongs to the last 0.01 fs below Nyquist, where halving the error again doubles the kernel.
Readings are taken in chunks and only the largest is kept (processMax()), so a meter's max-hold is exact while chunks that cannot raise it skip the crest refinement, and within a chunk that can, so does every vector of points that cannot. A reading reaches getDelay() samples back; a finite programme is completed with getTailPeak(). process() gives the same readings one per input sample to a detector that can wait that long for them (the Limiter's high-precision true-peak mode); the detectors that must answer within a few dozen samples use TruePeakEstimator instead.
Threading: a channel's state and the analyzer's scratch belong to the stream owner; processMax(), process() and getTailPeak() are not re-entrant. No allocation; the kernels are designed by the constructor.
| T | Sample type (float or double). |
Definition at line 764 of file TruePeakDetector.h.
|
inlinenoexcept |
Designs the three interpolation stages.
Definition at line 784 of file TruePeakDetector.h.
|
inlinestaticconstexprnoexcept |
Input samples one reading reaches back: the newest 8x grid point a call reads lies this many samples before the newest input sample, at most.
Definition at line 794 of file TruePeakDetector.h.
|
inlinenoexcept |
Peak of the zero-extended tail of a finite programme.
Reads enough zero samples on a copy of the channel that every grid point the last samples still reach is measured; the live history is not changed. Returns only the tail; combine it with the readings already taken. Same threading as processMax().
| channel | The channel's history. |
Definition at line 889 of file TruePeakDetector.h.
|
inlinenoexcept |
Appends samples to a channel and raises each peak[i] to the reading of the 8x grid points x[i] completes.
The per-sample form, for a detector that can wait for it: the reading for input sample n covers the reconstruction from x[n - getDelay()] to the last eighth point before x[n - getDelay() + 1], plus the crest centred on the eighth point before x[n - getDelay()], so it concerns the samples n - getDelay() - 1 .. n - getDelay() + 1. Every reading is the same arithmetic however the stream is cut into calls, and for finite input the largest of them is what processMax() returns. NaN readings are ignored (peak[i] keeps its value).
| channel | The channel's history (owned by the caller). |
| x | Input samples. |
| n | Sample count, 1 .. kChunk. |
| peak | Readings to raise, n values. |
| annex2 | When not null, n values raised to the BS.1770 Annex 2 table's phases over x[i - 11] .. x[i]: what a meter built on that table reads at x[i] between samples. Kept apart because that reading sits 6 samples back, not getDelay(). |
Definition at line 859 of file TruePeakDetector.h.
|
inlinenoexcept |
Appends samples to a channel and returns the largest finite reading among the 8x grid points they complete (0 if none).
Every crest refined by a call is centred on one of its grid points or on the last point before them, and a refinement raises its centre by at most a quarter. When none of those points exceeds atLeast / 1.25 the refinement is therefore skipped and the grid maximum is returned; otherwise every crest is refined. Either way the history advances the same way, so the running maximum of a stream does not depend on how it is cut into calls.
| channel | The channel's history (owned by the caller). |
| x | Input samples. |
| n | Sample count, 1 .. kChunk. |
| atLeast | The running maximum the caller already holds. |
Definition at line 818 of file TruePeakDetector.h.
|
staticconstexpr |
Most samples one processMax() call takes.
Definition at line 771 of file TruePeakDetector.h.
|
staticconstexpr |
Taps of the first (interval midpoint) stage.
Definition at line 770 of file TruePeakDetector.h.