|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
TPT State Variable Filter with simultaneous multi-output. More...
#include <StateVariableFilter.h>

Classes | |
| struct | ChannelState |
| struct | MultiOutput |
| Result struct for simultaneous multi-output processing. More... | |
Public Types | |
| enum class | Mode { LowPass , HighPass , BandPass , Notch , AllPass , Bell , LowShelf , HighShelf } |
| Filter output mode for processBlock/processSample. More... | |
Public Member Functions | |
| ~StateVariableFilter ()=default | |
| void | prepare (const AudioSpec &spec) noexcept |
| Prepares the filter. | |
| void | processBlock (AudioBufferView< T > buffer) noexcept |
| Processes an audio buffer in-place using the selected Mode. | |
| T | processSample (T input, int channel) noexcept |
| Processes a single sample (selected Mode output). | |
| MultiOutput | processMultiOutput (T input, int channel) noexcept |
| Processes a single sample returning LP, HP, BP simultaneously. | |
| void | reset () noexcept |
| Resets internal state. | |
| void | setCutoff (T hz) noexcept |
| Sets the cutoff/center frequency. | |
| void | setResonance (T resonance) noexcept |
| Sets the resonance amount. | |
| void | setQ (T q) noexcept |
| Sets the Q factor directly. | |
| void | setMode (Mode mode) noexcept |
| Sets the output mode. | |
| void | setGain (T dB) noexcept |
| Sets gain for Bell/Shelf modes (in dB). | |
| T | getCutoff () const noexcept |
| T | getResonance () const noexcept |
| T | getQ () const noexcept |
| T | getGain () const noexcept |
| Mode | getMode () const noexcept |
Protected Attributes | |
| std::array< ChannelState, kMaxChannels > | state_ {} |
| AudioSpec | spec_ {} |
| T | cutoff_ = T(1000) |
| T | resonance_ = T(0) |
| T | gainDb_ = T(0) |
| T | g_ = T(0) |
| T | R_ = T(1) |
| T | Rbell_ = T(1) |
| T | A_ = T(1) |
| Mode | mode_ = Mode::LowPass |
| T | effG_ = T(0) |
| T | effR_ = T(1) |
| T | a1_ = T(1) |
| T | a2_ = T(0) |
| T | a3_ = T(0) |
Static Protected Attributes | |
| static constexpr int | kMaxChannels = 16 |
TPT State Variable Filter with simultaneous multi-output.
| T | Sample type (float or double). |
Definition at line 91 of file StateVariableFilter.h.
|
strong |
Filter output mode for processBlock/processSample.
Definition at line 95 of file StateVariableFilter.h.
|
default |
|
inlinenoexcept |
Definition at line 289 of file StateVariableFilter.h.
|
inlinenoexcept |
Definition at line 292 of file StateVariableFilter.h.
|
inlinenoexcept |
Definition at line 293 of file StateVariableFilter.h.
|
inlinenoexcept |
Definition at line 291 of file StateVariableFilter.h.
|
inlinenoexcept |
Definition at line 290 of file StateVariableFilter.h.
|
inlinenoexcept |
Prepares the filter.
Invalid specs (sample rate not > 0, NaN included) are ignored and the previous state is kept. Clears the integrator state.
| spec | Audio environment. |
Definition at line 132 of file StateVariableFilter.h.
|
inlinenoexcept |
Processes an audio buffer in-place using the selected Mode.
| buffer | Audio data. |
Definition at line 144 of file StateVariableFilter.h.
|
inlinenoexcept |
Processes a single sample returning LP, HP, BP simultaneously.
This is the Level 2 API for DSP engineers who need multiple outputs from the same filter structure (e.g., crossover design, multiband split).
| input | Input sample. |
| channel | Channel index in [0, kMaxChannels). Out of range returns {input, 0, 0} (an LP/HP split still reconstructs the input) without touching any state. |
Definition at line 194 of file StateVariableFilter.h.
|
inlinenoexcept |
Processes a single sample (selected Mode output).
Modulation-friendly: you can call setCutoff() before every sample without artifacts, unlike biquad filters.
| input | Input sample. |
| channel | Channel index in [0, kMaxChannels). |
input unchanged if channel is out of range). Definition at line 176 of file StateVariableFilter.h.
|
inlinenoexcept |
Resets internal state.
Definition at line 201 of file StateVariableFilter.h.
|
inlinenoexcept |
Sets the cutoff/center frequency.
Can be called per-sample without artifacts (unlike biquads). Non-finite values (NaN/Inf) are ignored - they would poison the coefficients 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.
| hz | Frequency in Hz. |
Definition at line 223 of file StateVariableFilter.h.
|
inlinenoexcept |
Sets gain for Bell/Shelf modes (in dB).
| dB | Gain in decibels. Non-finite values are ignored. |
Definition at line 278 of file StateVariableFilter.h.
|
inlinenoexcept |
Sets the output mode.
Definition at line 268 of file StateVariableFilter.h.
|
inlinenoexcept |
Sets the Q factor directly.
For DSP engineers who think in Q rather than resonance 0-1.
| q | Quality factor, floored at 0.01 (0.5 = critically damped, 0.707 = Butterworth, 10+ = narrow). Non-finite values are ignored. |
Definition at line 257 of file StateVariableFilter.h.
|
inlinenoexcept |
Sets the resonance amount.
| resonance | 0.0 maps to Q = 0.5 (critically damped, no peak) and 1.0 to Q = 50 (a strong resonant peak, near but not at self-oscillation). Non-finite values are ignored. |
Definition at line 237 of file StateVariableFilter.h.
|
protected |
Definition at line 318 of file StateVariableFilter.h.
|
protected |
Definition at line 318 of file StateVariableFilter.h.
|
protected |
Definition at line 318 of file StateVariableFilter.h.
|
protected |
Definition at line 312 of file StateVariableFilter.h.
|
protected |
Definition at line 306 of file StateVariableFilter.h.
|
protected |
Definition at line 316 of file StateVariableFilter.h.
|
protected |
Definition at line 317 of file StateVariableFilter.h.
|
protected |
Definition at line 309 of file StateVariableFilter.h.
|
protected |
Definition at line 308 of file StateVariableFilter.h.
|
staticconstexprprotected |
Definition at line 296 of file StateVariableFilter.h.
|
protected |
Definition at line 313 of file StateVariableFilter.h.
|
protected |
Definition at line 310 of file StateVariableFilter.h.
|
protected |
Definition at line 311 of file StateVariableFilter.h.
|
protected |
Definition at line 307 of file StateVariableFilter.h.
|
protected |
Definition at line 305 of file StateVariableFilter.h.
|
protected |
Definition at line 304 of file StateVariableFilter.h.