|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Real-time safe EBU R128 loudness meter. More...
#include <LoudnessMeter.h>
Public Member Functions | |
| void | prepare (double sampleRate, int numChannels=2) noexcept |
| Prepares the meter and pre-calculates filter coefficients. | |
| void | prepare (const AudioSpec &spec) noexcept |
| Unified API preparation. | |
| void | processBlock (AudioBufferView< const T > buffer) noexcept |
| Processes a non-interleaved buffer view (read-only). | |
| void | process (const T *data, int numSamples) noexcept |
| Processes a mono block of samples. | |
| void | process (const T *left, const T *right, int numSamples) noexcept |
| Processes a stereo block of samples. | |
| T | getMomentaryLUFS () const noexcept |
| Reads the Momentary loudness (400 ms window). | |
| T | getShortTermLUFS () const noexcept |
| Reads the Short-term loudness (3 second window). | |
| T | getIntegratedLUFS () const noexcept |
| Computes the Integrated loudness using standard two-pass gating. | |
| T | getTruePeakDb () const noexcept |
| Returns the maximum true peak observed since the last reset. | |
| T | getLoudnessRange () const noexcept |
| Computes the EBU R128 Loudness Range (EBU Tech 3342). | |
| void | reset () noexcept |
| Clears all measurements and resets filters. | |
Real-time safe EBU R128 loudness meter.
Implements Momentary (400ms), Short-Term (3s), and Integrated (gated) measurements. Utilizes a constant-memory histogram for infinite integrated loudness tracking without memory allocation or O(N) CPU scaling, ensuring strict RT compliance.
All readout methods (getMomentaryLUFS, etc.) are lock-free and thread-safe to be called from GUI threads while the audio thread is processing.
| T | Sample type (float or double). |
Definition at line 56 of file LoudnessMeter.h.
|
inlinenoexcept |
Computes the Integrated loudness using standard two-pass gating.
Definition at line 199 of file LoudnessMeter.h.
|
inlinenoexcept |
Computes the EBU R128 Loudness Range (EBU Tech 3342).
Short-term (3 s) loudness sampled once per second, gated at -70 LUFS absolute and -20 LU relative; LRA is the spread between the 10th and 95th percentiles. O(bins) and real-time safe like the integrated gate.
Definition at line 263 of file LoudnessMeter.h.
|
inlinenoexcept |
Reads the Momentary loudness (400 ms window).
Definition at line 179 of file LoudnessMeter.h.
|
inlinenoexcept |
Reads the Short-term loudness (3 second window).
Definition at line 188 of file LoudnessMeter.h.
|
inlinenoexcept |
Returns the maximum true peak observed since the last reset.
Definition at line 249 of file LoudnessMeter.h.
|
inlinenoexcept |
Unified API preparation.
Definition at line 88 of file LoudnessMeter.h.
|
inlinenoexcept |
Prepares the meter and pre-calculates filter coefficients.
A non-finite or non-positive sample rate is ignored (conservative no-op keeping the previous state).
| sampleRate | Sample rate in Hz (must be > 0 and finite). |
| numChannels | Accepted for API symmetry; the channel layout is taken from each processed buffer (up to 2 channels are measured). |
Definition at line 70 of file LoudnessMeter.h.
|
inlinenoexcept |
Processes a mono block of samples.
| data | Pointer to mono audio data. |
| numSamples | Number of samples to process. |
Definition at line 116 of file LoudnessMeter.h.
|
inlinenoexcept |
Processes a stereo block of samples.
| left | Pointer to left channel data. |
| right | Pointer to right channel data. |
| numSamples | Number of samples per channel. |
Definition at line 148 of file LoudnessMeter.h.
|
inlinenoexcept |
Processes a non-interleaved buffer view (read-only).
The first two channels are measured; additional channels are ignored (multichannel spatial weighting is not implemented).
| buffer | AudioBufferView to analyze. |
Definition at line 101 of file LoudnessMeter.h.
|
inlinenoexcept |
Clears all measurements and resets filters.
Call from the stream owner or a setup thread, not concurrently with the process calls: the accumulators and filter states are plain writer-owned members.
Definition at line 319 of file LoudnessMeter.h.