|
Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
#include <svf.hpp>
Public Member Functions | |
| void | set_sample_rate (uint32_t sr) |
| void | set_cutoff (float freq_hz) |
| Set cutoff frequency in Hz. | |
| void | set_resonance (float q) |
| Set resonance. | |
| void | set_resonance_compensation (float k) |
| Set resonance compensation strength. | |
| void | set_mode (FilterMode mode) |
| Set filter output mode. | |
| void | process (float *buf, uint16_t frames) |
| Process a block of audio samples in-place. | |
| void | process_modulated (float *buf, uint16_t frames, const float *mod, float center, float depth, float lo=20.0f, float hi=20000.0f) |
| Process with per-sample exponential cutoff modulation. | |
| void | reset () |
| Reset filter state. | |
|
inline |
Process a block of audio samples in-place.
ZDF SVF — unconditionally stable, no oversampling needed.
| buf | Float audio buffer (modified in-place, [-1.0, 1.0]) |
| frames | Number of samples |
Definition at line 112 of file svf.hpp.
References sbl::widgets::proc::BandPass, sbl::widgets::proc::HighPass, sbl::widgets::proc::LowPass, and sbl::widgets::proc::Notch.
|
inline |
Process with per-sample exponential cutoff modulation.
Applies exponential modulation to the cutoff frequency per sample, recomputing ZDF coefficients each sample. The modulation signal is normalized [-1, 1] and depth is in octaves — perceptually uniform regardless of the center frequency.
This replaces the manual per-sample loop pattern: for (i = 0; i < n; ++i) { filter.set_cutoff(cutoff + lfo[i]); // WRONG: linear, broken filter.process(&buf[i], 1); }
With: filter.process_modulated(buf, n, lfo, cutoff, 2.0f); // ±2 octaves
| buf | Float audio buffer (modified in-place) |
| frames | Number of samples |
| mod | Modulation signal buffer (normalized [-1.0, 1.0]) |
| center | Center cutoff frequency in Hz |
| depth | Modulation depth in octaves (e.g., 2.0 = ±2 octaves) |
| lo | Minimum cutoff in Hz (default 20) |
| hi | Maximum cutoff in Hz (default 20000) |
Definition at line 162 of file svf.hpp.
References sbl::widgets::proc::BandPass, sbl::signal::exp_mod(), sbl::dsp::fast_tan_pif(), sbl::widgets::proc::HighPass, sbl::widgets::proc::LowPass, and sbl::widgets::proc::Notch.
|
inline |
|
inline |
Set cutoff frequency in Hz.
| freq_hz | Cutoff in Hz (e.g., 1000.0f) |
Definition at line 64 of file svf.hpp.
References sbl::dsp::fast_tan_pif().
|
inline |
|
inline |
|
inline |
Set resonance compensation strength.
Controls how much the input signal is attenuated as resonance increases: gain = 1 / (1 + q * k). This prevents the resonant peak from clipping during filter sweeps.
k = 0 No compensation (default, backward compatible) k = 2 Gentle drop (~33% volume at full resonance) k = 4 Strong drop (~20% volume at full resonance)
| k | Compensation amount (0.0 = off) |
|
inline |