Class thl::dsp::probe::LevelProbe#
-
class LevelProbe : public thl::dsp::probe::ProbeBase#
Inheritance diagram for thl::dsp::probe::LevelProbe:
Collaboration diagram for thl::dsp::probe::LevelProbe:
Peak and RMS of every channel, measured on the audio thread, read from any thread.
Peak: the highest |x| since the reader last took it (take_peak()), so a reader polling at screen rate misses no peak between two of its frames; peak() looks without taking.
RMS: a one-pole mean square over rms_window_ms() (300 ms by default, a VU’s integration time), the value at the end of the last block. Both linear (dsp::utils::gain_to_db() for dB). Readers on several threads may read; take_peak() is for one of them. A non-finite sample counts as silence (as for the RMS); channels prepared but missing from a block read as silence; while inactive both keep the last block’s values, and the first block after starts from 0.
Up to k_max_channels channels, held in place: prepare() never frees what a reader reads.
Public Functions
-
explicit LevelProbe(float rms_window_ms = k_default_rms_window_ms)#
-
virtual void prepare(double sample_rate, size_t max_block_size, size_t num_channels) override#
Control thread: blocks of up to
max_block_sizesamples andnum_channelschannels will come atsample_rate.
-
virtual void reset() override#
Audio thread: forgets what it has seen, as after prepare(): the next block starts anew.
-
inline size_t num_channels() const#
-
inline float rms_window_ms() const#
-
float peak(size_t channel) const#
The highest |x| of channel
channelsince the last take_peak() (0 for no channel).
-
float rms(size_t channel) const#
The RMS of channel
channelat the end of the last block (0 for no channel).
Public Static Attributes
-
static constexpr float k_default_rms_window_ms = 300.0f#
-
static constexpr size_t k_max_channels = 16#
Protected Functions
-
virtual void observe(const thl::core::BufferView &block) override#
Audio thread: what the probe does with a block. Must not change it, allocate or wait.