filter.hpp — filters and EQ
Namespace wauvio::filter.
SVFilter
Topology-preserving-transform state-variable filter. Mode { LowPass, HighPass, BandPass }, fields mode, cutoff (Hz), Q (0.707 default; higher resonates). After changing cutoff or Q call update_coeffs(sample_rate) (or use set_params(fc, q, sr)). tick(x, sample_rate) processes one sample; process(buf) a buffer; reset() clears state.
One-pole filters
LowPassFilter and HighPassFilter are legacy 1-pole filters kept for compatibility; constructed with a cutoff, adjustable with set_cutoff, used via tick / process.
BiquadEQ and ParametricEQ
BiquadEQ is one band using RBJ Audio-EQ-Cookbook formulas: Type { LowShelf, HighShelf, Peak }, freq_hz, gain_db, Q. ParametricEQ bundles three: low_shelf (200 Hz), peak (1 kHz) and high_shelf (6 kHz), all at 0 dB so it starts transparent. It processes mono or stereo buffers.
Full API listing
wauvio/core/filter.hpp
wauvio::filter::class SVFilter
// §13 STATE VARIABLE FILTER (SVF)
// Topology-preserving TPT form (Vadim Zavalishin) - no pre-warping needed.
// Provides simultaneous LP, HP, and BP outputs.
// Q > 0.5: resonance; Q = 0.707: Butterworth; Q → ∞: self-oscillation.
class SVFilter
public:
enum class Mode { LowPass, HighPass, BandPass };
Mode mode = Mode::LowPass;
double cutoff = 1000.0; ///< Hz
double Q = 0.707; ///< Resonance (0.5–30 typical range)
SVFilter() = default;
SVFilter(Mode m, double fc, double q = 0.707) : mode(m), cutoff(fc), Q(q) {}
void set_params(double fc, double q, int sample_rate = 0)
/// Process one sample. Call update_coeffs() after changing params.
float tick(float x, int sample_rate) noexcept
void process(Buffer& buf, int sample_rate = 0)
void reset() noexcept { s1_ = s2_ = 0.0f; }
void update_coeffs(int sample_rate) noexcept
wauvio::filter::class LowPassFilter
// §14 LEGACY 1-POLE FILTERS (kept for compatibility with existing modules)
class LowPassFilter
public:
explicit LowPassFilter(double cutoff_hz = 1000.0, int sample_rate = 0)
void set_cutoff(double fc, int sr = 0)
float tick(float x) noexcept { z1_ += alpha_ * (x - z1_); return z1_; }
void process(Buffer& b) noexcept { for (auto& s : b) s = tick(s); }
void reset() noexcept { z1_ = 0.0f; }
wauvio::filter::class HighPassFilter
class HighPassFilter
public:
explicit HighPassFilter(double cutoff_hz = 200.0, int sample_rate = 0)
void set_cutoff(double fc, int sr = 0)
float tick(float x) noexcept
void process(Buffer& b) noexcept { for (auto& s : b) s = tick(s); }
void reset() noexcept { xp_ = yp_ = 0.0f; }
wauvio::filter::class BiquadEQ
// §14b PARAMETRIC EQ
// Three independent biquad bands: low shelf, peak/notch, high shelf.
// Each band is independently bypassable. Uses Robert Bristow-Johnson's
// Audio EQ Cookbook formulae.
/// Single biquad EQ band.
class BiquadEQ
public:
enum class Type { LowShelf, HighShelf, Peak };
Type type = Type::Peak;
double freq_hz = 1000.0; ///< Centre / corner frequency
double gain_db = 0.0; ///< Boost/cut in dB (Peak); shelf gain for shelves
double Q = 0.707; ///< Bandwidth / slope control
BiquadEQ() = default;
BiquadEQ(Type t, double f, double g, double q = 0.707)
: type(t), freq_hz(f), gain_db(g), Q(q) {}
float tick(float x, int sample_rate) noexcept
void process(Buffer& buf, int sample_rate = 0)
void reset() noexcept { x1_ = x2_ = y1_ = y2_ = 0.0f; }
void update_coeffs(int sample_rate) noexcept
wauvio::filter::class ParametricEQ
/// Three-band parametric EQ: low shelf + peak + high shelf.
/// Each band can be bypassed independently by setting gain_db = 0.
class ParametricEQ
public:
BiquadEQ low_shelf { BiquadEQ::Type::LowShelf, 200.0, 0.0, 0.707 };
BiquadEQ peak { BiquadEQ::Type::Peak, 1000.0, 0.0, 0.707 };
BiquadEQ high_shelf { BiquadEQ::Type::HighShelf, 6000.0, 0.0, 0.707 };
float tick(float x, int sample_rate) noexcept
void process(Buffer& buf, int sample_rate = 0)
void process(StereoBuffer& buf, int sample_rate = 0)
void reset() noexcept