std1.0.0-beta-7 SafeC docs

std :: dsp::biquad

Struct std::Biquad

#include <std/dsp/biquad.h> source

struct Biquad {
    double b0;
    double b1;
    double b2;
    double a1;
    double a2;
    double z1;
    double z2;
}

Fields

§double b0source
§double b1source
§double b2source
§double a1source
§double a2source
§double z1source
§double z2source

Methods

§double process(double x)source · definition
§void reset()source · definition
§void process_block([]const double in, []double out)source · definition

process() over a block: out[i] = filter(in[i]), keeping the state in registers for the whole block. in == out is allowed. Real-time safe.

§double response_mag(double fs, double freqHz) constsource · definition

Z-domain frequency response at 'freqHz' (evaluates H(e^{jomega}), omega = 2pi*freqHz/fs) — magnitude (linear, not dB) and phase (radians).

§double response_phase(double fs, double freqHz) constsource · definition
§static struct Biquad new(double b0, double b1, double b2, double a1, double a2)source · definition

A section with these (a0-normalized) coefficients and zero state.

§static struct Biquad lowpass(double fs, double f0, double q)source · definition

fs = sample rate (Hz), f0 = cutoff/center frequency (Hz), q = Q factor (> 0; higher = narrower/more resonant).

§static struct Biquad highpass(double fs, double f0, double q)source · definition
§static struct Biquad bandpass(double fs, double f0, double q)source · definition

constant 0 dB peak gain

§static struct Biquad notch(double fs, double f0, double q)source · definition
§static struct Biquad allpass(double fs, double f0, double q)source · definition
§static struct Biquad peaking(double fs, double f0, double q, double dbGain)source · definition

dbGain: boost (positive) or cut (negative) at f0, in decibels.

§static struct Biquad lowshelf(double fs, double f0, double s, double dbGain)source · definition

s: shelf slope (1.0 = maximally steep without overshoot — the RBJ cookbook's own recommended default when no other constraint applies).

§static struct Biquad highshelf(double fs, double f0, double s, double dbGain)source · definition
§static struct Biquad bilinear( double B0, double B1, double B2, double A0, double A1, double A2, double fs, )source · definition

General analog-to-digital 2nd-order section via the bilinear transform. H(s) = (B2s^2 + B1s + B0) / (A2s^2 + A1s + A0) is the analog prototype; fs is the target digital sample rate. Frequencies in H(s) should already be pre-warped (w_analog = 2fstan(w_digital/(2*fs))) by the caller if matching a specific digital cutoff matters — this function performs the algebraic substitution only, the same division of responsibility real bilinear-transform tools use.