Class thl::dsp::probe::LevelProbe#

class LevelProbe : public thl::dsp::probe::ProbeBase#

Inheritance diagram for thl::dsp::probe::LevelProbe:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "1" [label="thl::dsp::probe::LevelProbe" tooltip="thl::dsp::probe::LevelProbe" fillcolor="#BFBFBF"] "2" [label="thl::dsp::probe::ProbeBase" tooltip="thl::dsp::probe::ProbeBase"] "1" -> "2" [dir=forward tooltip="public-inheritance"] }

Collaboration diagram for thl::dsp::probe::LevelProbe:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "1" [label="thl::dsp::probe::LevelProbe" tooltip="thl::dsp::probe::LevelProbe" fillcolor="#BFBFBF"] "2" [label="thl::dsp::probe::ProbeBase" tooltip="thl::dsp::probe::ProbeBase"] "1" -> "2" [dir=forward tooltip="public-inheritance"] }

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_size samples and num_channels channels will come at sample_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 channel since the last take_peak() (0 for no channel).

float take_peak(size_t channel)#

peak(), and starts the next one from 0.

float rms(size_t channel) const#

The RMS of channel channel at 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.