Class thl::dsp::probe::ProbeBase#
-
class ProbeBase#
Inheritance diagram for thl::dsp::probe::ProbeBase:
Something that watches a signal without changing it: a meter, an analyser’s tap.
Not a BaseProcessor: a probe gets every block read-only, is never a node of a graph (attaching or removing one is not an edit of its structure) and has no latency, dry signal or parameters of its own. Whoever runs the signal (a Graph, a processor) calls process() with every block at the point the probe watches; the probe does the little the audio thread must do (copy the block, keep a peak) and leaves the rest (FFT, smoothing, drawing) to its reader.
Threads: prepare() may allocate and runs on the control thread with audio stopped (or before the probe is attached); readers must not read during it either (hosts call it on the main thread, so readers on the main thread, e.g. a UI timer, are safe). process(), observe() and reset() run on the audio thread. set_active(), is_active() and latency_samples() may be called from any thread.
Subclassed by thl::dsp::probe::LevelProbe, thl::dsp::probe::SampleProbe
Public Functions
-
ProbeBase() = default#
-
virtual ~ProbeBase()#
-
virtual void prepare(double sample_rate, size_t max_block_size, size_t num_channels) = 0#
Control thread: blocks of up to
max_block_sizesamples andnum_channelschannels will come atsample_rate.
-
inline void process(const thl::core::BufferView &block, uint32_t latency_samples)#
Audio thread: one block at the watched point,
latency_samplesbehind the signal’s input there (so a reader can align two probes, e.g.a node’s input and output). Skipped while inactive; the first block after the probe was inactive starts with reset(), so nothing from before the pause is joined to what follows it.
-
inline virtual void reset()#
Audio thread: forgets what it has seen, as after prepare(): the next block starts anew.
-
inline void set_active(bool active)#
Any thread: an inactive probe costs nothing, e.g. an analyser that is not visible.
-
inline bool is_active() const#
-
inline uint32_t latency_samples() const#
Any thread: the latency of the last block observed.
Not tied to the samples a reader has drained (it may already be the next block’s): enough to align displays, not single samples.
Protected Functions
-
virtual void observe(const thl::core::BufferView &block) = 0#
Audio thread: what the probe does with a block. Must not change it, allocate or wait.
-
ProbeBase() = default#