Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Public Member Functions | List of all members
sbl::widgets::proc::Svf Class Reference

#include <svf.hpp>

Collaboration diagram for sbl::widgets::proc::Svf:

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.
 

Detailed Description

Definition at line 54 of file svf.hpp.

Member Function Documentation

◆ process()

void sbl::widgets::proc::Svf::process ( float *  buf,
uint16_t  frames 
)
inline

Process a block of audio samples in-place.

ZDF SVF — unconditionally stable, no oversampling needed.

Parameters
bufFloat audio buffer (modified in-place, [-1.0, 1.0])
framesNumber 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.

◆ process_modulated()

void sbl::widgets::proc::Svf::process_modulated ( float *  buf,
uint16_t  frames,
const float *  mod,
float  center,
float  depth,
float  lo = 20.0f,
float  hi = 20000.0f 
)
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

Parameters
bufFloat audio buffer (modified in-place)
framesNumber of samples
modModulation signal buffer (normalized [-1.0, 1.0])
centerCenter cutoff frequency in Hz
depthModulation depth in octaves (e.g., 2.0 = ±2 octaves)
loMinimum cutoff in Hz (default 20)
hiMaximum 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.

Here is the call graph for this function:

◆ reset()

void sbl::widgets::proc::Svf::reset ( )
inline

Reset filter state.

Definition at line 208 of file svf.hpp.

◆ set_cutoff()

void sbl::widgets::proc::Svf::set_cutoff ( float  freq_hz)
inline

Set cutoff frequency in Hz.

Parameters
freq_hzCutoff in Hz (e.g., 1000.0f)

Definition at line 64 of file svf.hpp.

References sbl::dsp::fast_tan_pif().

Here is the call graph for this function:

◆ set_mode()

void sbl::widgets::proc::Svf::set_mode ( FilterMode  mode)
inline

Set filter output mode.

Definition at line 102 of file svf.hpp.

◆ set_resonance()

void sbl::widgets::proc::Svf::set_resonance ( float  q)
inline

Set resonance.

Parameters
q0.0 = no resonance (flat), 1.0 = maximum resonance

Definition at line 75 of file svf.hpp.

◆ set_resonance_compensation()

void sbl::widgets::proc::Svf::set_resonance_compensation ( float  k)
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)

Parameters
kCompensation amount (0.0 = off)

Definition at line 96 of file svf.hpp.

◆ set_sample_rate()

void sbl::widgets::proc::Svf::set_sample_rate ( uint32_t  sr)
inline
Note
All public methods are ISR-safe — bounded computation, no I/O.

Definition at line 58 of file svf.hpp.


The documentation for this class was generated from the following file: