Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::MultiChannelMeterT< SampleType > Class Template Reference

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

Detailed Description

template<typename SampleType = float>
class pulp::signal::MultiChannelMeterT< SampleType >

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().

Member Function Documentation

◆ features()

template<typename SampleType = float>
MeterFeatures pulp::signal::MultiChannelMeterT< SampleType >::features ( ) const
inlinenoexcept

The feature set the meter was prepared with.

◆ loudness_supported()

template<typename SampleType = float>
bool pulp::signal::MultiChannelMeterT< SampleType >::loudness_supported ( ) const
inlinenoexcept

Whether the prepared sample rate and speaker layout support BS.1770 loudness.

False does not disable the non-loudness meter fields.

◆ prepare() [1/3]

template<typename SampleType = float>
void pulp::signal::MultiChannelMeterT< SampleType >::prepare ( double sample_rate,
int num_channels )
inline

◆ prepare() [2/3]

template<typename SampleType = float>
void pulp::signal::MultiChannelMeterT< SampleType >::prepare ( double sample_rate,
int num_channels,
const LoudnessChannelRole * roles )
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.

◆ prepare() [3/3]

template<typename SampleType = float>
void pulp::signal::MultiChannelMeterT< SampleType >::prepare ( double sample_rate,
int num_channels,
const LoudnessChannelRole * roles,
MeterFeatures features )
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

  1. Peak, RMS, and clip detection are always measured.

◆ process()

template<typename SampleType = float>
void pulp::signal::MultiChannelMeterT< SampleType >::process ( const SampleType *const * channels,
int num_channels,
int num_samples )
inline

Process a block of interleaved or deinterleaved audio.

channels: array of channel pointers. num_samples: samples per channel.

◆ reset()

template<typename SampleType = float>
void pulp::signal::MultiChannelMeterT< SampleType >::reset ( )
inline

◆ snapshot()

template<typename SampleType = float>
const MultiChannelMeterData & pulp::signal::MultiChannelMeterT< SampleType >::snapshot ( ) const
inline

Get the latest metering snapshot.

◆ detail::MultiChannelMeterTestAccess

template<typename SampleType = float>
friend struct detail::MultiChannelMeterTestAccess
friend

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