Class thl::dsp::utils::BandSplitter#

class BandSplitter : public thl::dsp::BaseProcessor#

Inheritance diagram for thl::dsp::utils::BandSplitter:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "2" [label="thl::dsp::BaseProcessor" tooltip="thl::dsp::BaseProcessor"] "3" [label="thl::dsp::fx::StereoWidenerImpl" tooltip="thl::dsp::fx::StereoWidenerImpl"] "1" [label="thl::dsp::utils::BandSplitter" tooltip="thl::dsp::utils::BandSplitter" fillcolor="#BFBFBF"] "4" [label="thl::dsp::utils::MultibandLimiterImpl" tooltip="thl::dsp::utils::MultibandLimiterImpl"] "3" -> "1" [dir=forward tooltip="public-inheritance"] "1" -> "2" [dir=forward tooltip="public-inheritance"] "4" -> "1" [dir=forward tooltip="public-inheritance"] }

Collaboration diagram for thl::dsp::utils::BandSplitter:

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

Splits a signal into num_bands() bands with Linkwitz-Riley crossovers in series, band 0 the lowest.

Each band also goes through the all-passes of the crossovers above it, so the bands sum to the input through the all-passes of every crossover: their sum before processing is the dry signal.

A processor derives from it and implements process(): call process_band() for bands 0 to num_bands() - 1 in this order, with the input in the buffer of band 0. Every band must be processed in every block: each band reads what the band before it left behind, and its filters would otherwise miss that block.

Real-Time Safety

process_band(), set_frequency(), set_frequencies(), read_crossover_parameters() and reset() are real-time safe: no allocation, no locks. prepare() allocates.

Subclassed by thl::dsp::fx::StereoWidenerImpl, thl::dsp::utils::MultibandLimiterImpl

Public Functions

explicit BandSplitter(size_t num_bands, size_t order)#

Until set_frequency() is called, the crossovers are log-spaced from 100 Hz to 10 kHz.

BandSplitter(const BandSplitter&) = delete#
BandSplitter &operator=(const BandSplitter&) = delete#
virtual void prepare(const double &sample_rate, const size_t &samples_per_block, const size_t &num_channels) override#
void set_frequency(size_t crossover, float frequency)#

Sets the target of the crossover between bands crossover and crossover + 1, blocked at its neighbours (they stay): one crossover moved, e.g.

dragged. For several at once use set_frequencies(), which does not depend on the order. Call it from the audio thread, before process_band() for band 0; a change takes effect from the next block. A non-finite frequency is ignored. The requested frequency is kept: prepare() at another sample rate clamps it again from it, so a limit of one rate does not stick.

void set_frequencies(std::span<const float> frequencies)#

Sets the targets of every crossover at once (frequencies: one per crossover, lowest first; a non-finite one leaves that crossover’s request as it is), independent of any order: the requests are sorted, so crossing ones become the same boundaries in order, and one that sweeps past another hands over continuously.

Audio thread, as set_frequency().

float get_frequency(size_t crossover) const#

The target of crossover as applied: clamped between its neighbours and below Nyquist.

inline size_t num_bands() const#
virtual void reset() override#

Clears every crossover’s state and ends the glides at their targets; the next block starts with band 0 (audio thread).

Public Static Attributes

static constexpr double k_smoothing_seconds = 0.005#

Protected Functions

virtual float get_crossover_parameter_float(size_t crossover, uint32_t modulation_offset = 0)#

The frequency (Hz) of crossover crossover (0: between bands 0 and 1), for a processor whose crossovers are parameters: read_crossover_parameters() reads every crossover through it and applies them together (set_frequencies(): independent of order, crossing ones are sorted).

Non-finite (the default): that crossover keeps what set_frequency() gave it.

void read_crossover_parameters(uint32_t modulation_offset)#

Reads every crossover at modulation_offset (get_crossover_parameter_float()) and applies them with set_frequencies().

Call it at the start of process(), before process_band().

void process_band(thl::core::BufferView buffer, size_t band_index)#

Writes band band_index into buffer. For band 0, buffer holds the input on entry.