Audio-thread metering processor. More...
#include <multi_channel_meter.hpp>
Public Member Functions | |
| void | prepare (double sample_rate, int num_channels) |
| void | prepare (double sample_rate, int num_channels, const LoudnessChannelRole *roles, MeterFeatures features) |
| Prepare with a feature set. | |
| MeterFeatures | features () const noexcept |
| The feature set the meter was prepared with. | |
| void | prepare (double sample_rate, int num_channels, const LoudnessChannelRole *roles) |
| Prepare the loudness meter with an explicit speaker layout and every feature (MeterFeatures::all), whatever an earlier prepare() selected. | |
| void | process (const SampleType *const *channels, int num_channels, int num_samples) |
| Process a block of interleaved or deinterleaved audio. | |
| const MultiChannelMeterData & | snapshot () const |
| Get the latest metering snapshot. | |
| bool | loudness_supported () const noexcept |
| Whether the prepared sample rate and speaker layout support BS.1770 loudness. | |
| void | reset () |
Friends | |
| struct | detail::MultiChannelMeterTestAccess |
Audio-thread metering processor.
Computes sample peak, RMS, stereo correlation, clip detection, and the channel-based BS.1770-5 loudness core for up to kMaxMeterChannels. Loudness uses K-weighting, 400 ms blocks at 75% overlap, and the -70 LUFS absolute / -10 LU relative integrated gates. Finite inputs beyond +/-kMaxMeterInputMagnitude are treated as deterministic over-range audio and clipped to that supported-domain boundary.
The default layouts are mono, stereo, L/R/C, quad, 5.0, 5.1, and 7.1 in L/R/C/LFE/Ls/Rs/Lrs/Rrs order. There is no implicit seven-channel mapping or default above eight channels; pass explicit roles for those cases. Roles may repeat when multiple input channels share the same BS.1770 weighting. Roles outside this enum are unsupported. loudness_supported() reports whether the prepared sample rate and layout have an honest BS.1770 interpretation; peak, RMS, correlation, and clip metering remain available when they do not. This supplies the EBU short-term (3 s) and loudness-range core. Scale/UI behavior and true peak remain outside this processor.
process() works a block at a time: it splits the block at loudness-hop boundaries, measures each piece's peak, energy, and correlation with vector reductions, and runs the K-weighting recursion for channel pairs as one two-lane vector. A piece holding any non-finite or over-range sample is measured sample by sample with the sanitizing rules above instead, so the readings follow the same definitions either way; only the summation order of the energy accumulators differs, at double-precision rounding.
Call process() from the audio callback. Read results via snapshot().
|
inlinenoexcept |
The feature set the meter was prepared with.
|
inlinenoexcept |
Whether the prepared sample rate and speaker layout support BS.1770 loudness.
False does not disable the non-loudness meter fields.
|
inline |
|
inline |
Prepare the loudness meter with an explicit speaker layout and every feature (MeterFeatures::all), whatever an earlier prepare() selected.
Integrated gating uses a prepared 0.01 LU Fenwick histogram: memory and update cost remain fixed regardless of measurement duration. Allocation occurs only here.
|
inline |
Prepare with a feature set.
Without MeterFeatures::loudness the loudness fields stay at their empty values and loudness_supported() reports false; without MeterFeatures::correlation the correlation reads
|
inline |
Process a block of interleaved or deinterleaved audio.
channels: array of channel pointers. num_samples: samples per channel.
|
inline |
|
inline |
Get the latest metering snapshot.
|
friend |