|
DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
|
TPT State Variable Filter with simultaneous multi-output. More...
#include <StateVariableFilter.h>

Classes | |
| 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 Types | |
| using | ChannelState = detail::TptSvfState< T > |
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 92 of file StateVariableFilter.h.
|
protected |
Definition at line 312 of file StateVariableFilter.h.
|
strong |
Filter output mode for processBlock/processSample.
Definition at line 96 of file StateVariableFilter.h.
|
default |
|
inlinenoexcept |
Definition at line 303 of file StateVariableFilter.h.
|
inlinenoexcept |
Definition at line 306 of file StateVariableFilter.h.
|
inlinenoexcept |
Definition at line 307 of file StateVariableFilter.h.
|
inlinenoexcept |
Definition at line 305 of file StateVariableFilter.h.
|
inlinenoexcept |
Definition at line 304 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 133 of file StateVariableFilter.h.
|
inlinenoexcept |
Processes an audio buffer in-place using the selected Mode.
A non-finite integrator state (a NaN or Inf input reached the recursion) is cleared at the end of the block, so the channel recovers on the next block instead of producing NaN until reset().
| buffer | Audio data. |
Definition at line 150 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 208 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 190 of file StateVariableFilter.h.
|
inlinenoexcept |
Resets internal state.
Definition at line 215 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 237 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 292 of file StateVariableFilter.h.
|
inlinenoexcept |
Sets the output mode.
Definition at line 282 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 271 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 251 of file StateVariableFilter.h.
|
protected |
Definition at line 328 of file StateVariableFilter.h.
|
protected |
Definition at line 328 of file StateVariableFilter.h.
|
protected |
Definition at line 328 of file StateVariableFilter.h.
|
protected |
Definition at line 322 of file StateVariableFilter.h.
|
protected |
Definition at line 316 of file StateVariableFilter.h.
|
protected |
Definition at line 326 of file StateVariableFilter.h.
|
protected |
Definition at line 327 of file StateVariableFilter.h.
|
protected |
Definition at line 319 of file StateVariableFilter.h.
|
protected |
Definition at line 318 of file StateVariableFilter.h.
|
staticconstexprprotected |
Definition at line 310 of file StateVariableFilter.h.
|
protected |
Definition at line 323 of file StateVariableFilter.h.
|
protected |
Definition at line 320 of file StateVariableFilter.h.
|
protected |
Definition at line 321 of file StateVariableFilter.h.
|
protected |
Definition at line 317 of file StateVariableFilter.h.
|
protected |
Definition at line 315 of file StateVariableFilter.h.
|
protected |
Definition at line 314 of file StateVariableFilter.h.