|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
4-pole resonant ladder filter (Moog topology, TPT discretization). More...
#include <LadderFilter.h>

Classes | |
| struct | ChannelState |
Public Types | |
| enum class | Mode { LP6 , LP12 , LP18 , LP24 , BP12 , HP24 } |
| Defines the frequency response mode of the filter output. More... | |
Public Member Functions | |
| ~LadderFilter ()=default | |
| void | prepare (const AudioSpec &spec) noexcept |
| Prepares the filter with the current audio environment. | |
| void | processBlock (AudioBufferView< T > buffer) noexcept |
| Processes an audio buffer in-place (thread-safe vs. setters). | |
| T | processSample (T input, int channel) noexcept |
| Processes a single sample on one channel. | |
| void | reset () noexcept |
| Clears the internal integrator state. | |
| void | setCutoff (T hz) noexcept |
| Sets the cutoff frequency (thread-safe, lock-free). | |
| void | setResonance (T amount) noexcept |
| Sets resonance amount (thread-safe, lock-free). | |
| void | setDrive (T amount) noexcept |
| Sets the nonlinear drive amount (thread-safe, lock-free). | |
| void | setMode (Mode mode) noexcept |
| Sets the filter output mode (thread-safe, lock-free). | |
| T | getCutoff () const noexcept |
| T | getResonance () const noexcept |
| T | getDrive () const noexcept |
| Mode | getMode () const noexcept |
Protected Attributes | |
| std::array< ChannelState, kMaxChannels > | state_ {} |
| AudioSpec | spec_ {} |
| std::atomic< T > | cutoff_ {T(1000)} |
| std::atomic< T > | resonance_ {T(0)} |
| std::atomic< T > | drive_ {T(1)} |
| std::atomic< T > | g_ {T(0)} |
| std::atomic< Mode > | mode_ {Mode::LP24} |
Static Protected Attributes | |
| static constexpr int | kMaxChannels = 16 |
4-pole resonant ladder filter (Moog topology, TPT discretization).
Four cascaded one-pole TPT lowpass stages with global feedback. The zero-delay feedback loop is resolved analytically each sample, and the multimode outputs are tap mixes of the cascade. processBlock() snapshots the parameters once per block and dispatches to a per-mode template instantiation, so the sample loop carries no branches.
Contract notes:
| T | Sample type (float or double). Must satisfy FloatType concept. |
Definition at line 62 of file LadderFilter.h.
|
strong |
Defines the frequency response mode of the filter output.
Definition at line 66 of file LadderFilter.h.
|
default |
|
inlinenoexcept |
Definition at line 231 of file LadderFilter.h.
|
inlinenoexcept |
Definition at line 233 of file LadderFilter.h.
|
inlinenoexcept |
Definition at line 234 of file LadderFilter.h.
|
inlinenoexcept |
Definition at line 232 of file LadderFilter.h.
|
inlinenoexcept |
Prepares the filter with the current audio environment.
Invalid specs (sample rate not > 0, NaN included) are ignored and the previous state is kept. Clears the integrator state.
| spec | Audio specification including sample rate. |
Definition at line 88 of file LadderFilter.h.
|
inlinenoexcept |
Processes an audio buffer in-place (thread-safe vs. setters).
Takes an atomic snapshot of the current parameters and dispatches to a branchless inner loop instantiated per mode.
| buffer | View of the multi-channel audio data to process. |
Definition at line 104 of file LadderFilter.h.
|
inlinenoexcept |
Processes a single sample on one channel.
Convenience per-sample entry point mirroring Biquad. For bulk processing prefer processBlock(), which snapshots the parameters and derives the loop coefficients once per block instead of per sample.
| input | Input sample. |
| channel | Channel index in [0, kMaxChannels). |
input unchanged if channel is out of range). Definition at line 144 of file LadderFilter.h.
|
inlinenoexcept |
Clears the internal integrator state.
Should be called when playback stops or continuity is broken to prevent clicks.
Definition at line 172 of file LadderFilter.h.
|
inlinenoexcept |
Sets the cutoff frequency (thread-safe, lock-free).
Non-finite values (NaN/Inf) are ignored - they would poison the integrator gain permanently otherwise. Before prepare() the sample rate is unknown, so the raw request is stored and clamped to [20, sampleRate * 0.499] once prepare() runs (getCutoff() then reports the clamped value).
| hz | Cutoff frequency in Hz. |
Definition at line 191 of file LadderFilter.h.
|
inlinenoexcept |
Sets the nonlinear drive amount (thread-safe, lock-free).
| amount | Drive multiplier, floored at 0.1. Values <= 1.0 keep the feedback path linear; > 1.0 saturates it (analog-style resonance compression). Non-finite values are ignored. |
Definition at line 216 of file LadderFilter.h.
|
inlinenoexcept |
Sets the filter output mode (thread-safe, lock-free).
| mode | Target frequency response type. |
Definition at line 226 of file LadderFilter.h.
|
inlinenoexcept |
Sets resonance amount (thread-safe, lock-free).
| amount | Range [0.0, 1.0]. Values near 1.0 induce self-oscillation (see the class notes on drive for loop stability). Non-finite values are ignored. |
Definition at line 204 of file LadderFilter.h.
|
protected |
Definition at line 253 of file LadderFilter.h.
|
protected |
Definition at line 255 of file LadderFilter.h.
|
protected |
Definition at line 256 of file LadderFilter.h.
|
staticconstexprprotected |
Definition at line 237 of file LadderFilter.h.
|
protected |
Definition at line 257 of file LadderFilter.h.
|
protected |
Definition at line 254 of file LadderFilter.h.
|
protected |
Definition at line 250 of file LadderFilter.h.
|
protected |
Definition at line 249 of file LadderFilter.h.