Contents

class

SushiDSP::Biquad

Direct Form I biquad filter with RBJ cookbook coefficient derivation, its coefficients and state in double behind a float sample interface (docs/archive/superpowers/specs/2026-09-07-grid-knee-antialiasing-design.md section 15).

Declared in
include/SushiDSP/math/Biquad.hpp

Public member functions

void set_low_pass(double sample_rate, double cutoff_hz, double q)

Configures this filter as a low-pass with the given cutoff and Q.

Parameters

sample_rate

Sample rate in Hz.

cutoff_hz

Cutoff frequency in Hz.

q

Quality factor (0.707 = Butterworth).

void set_one_pole_low_pass(double sample_rate, double cutoff_hz)

Configures this filter as a first-order (one-pole) low-pass.

A single RC section, bilinear-transformed with the corner prewarped, so the second numerator and denominator taps are zero. This is the right shape for a physical RC pole - a Butterworth biquad would roll off at twice the rate a real one does.

Parameters

sample_rate

Sample rate in Hz.

cutoff_hz

Corner frequency in Hz, where the response is -3 dB.

void set_first_order_high_pass(double sample_rate, double cutoff_hz)

Configures this filter as a first-order (one-pole) high-pass.

A single RC section mapped by the impulse-invariant pole R = exp(-2*pi*fc/fs): unity at Nyquist and -3 dB at the corner (include/SushiDSP/README.md).

Parameters

cutoff_hz

Corner frequency in Hz, where the response is -3 dB.

Precondition

0 < cutoff_hz < sample_rate / 2

void set_high_pass(double sample_rate, double cutoff_hz, double q)

Configures this filter as a high-pass with the given cutoff and Q.

Parameters

sample_rate

Sample rate in Hz.

cutoff_hz

Cutoff frequency in Hz.

q

Quality factor (0.707 = Butterworth).

Precondition

cutoff_hz / sample_rate >= 1e-4; use set_first_order_high_pass for corners that low.

void set_low_shelf(double sample_rate, double cutoff_hz, double gain_db, double q)

Configures this filter as a low-shelf with the given corner, gain, and Q.

Parameters

sample_rate

Sample rate in Hz.

cutoff_hz

Shelf corner frequency in Hz.

gain_db

Shelf gain in decibels (positive boosts, negative cuts).

q

Shelf slope parameter (RBJ cookbook S=1 equivalent at q=1.0).

void set_high_shelf(double sample_rate, double cutoff_hz, double gain_db, double q)

Configures this filter as a high-shelf with the given corner, gain, and Q.

Parameters

sample_rate

Sample rate in Hz.

cutoff_hz

Shelf corner frequency in Hz.

gain_db

Shelf gain in decibels.

q

Shelf slope parameter.

void set_peaking(double sample_rate, double center_hz, double gain_db, double q)

Configures this filter as a peaking EQ with the given center, gain, and Q.

Parameters

sample_rate

Sample rate in Hz.

center_hz

Center frequency in Hz.

gain_db

Peak gain in decibels (positive boosts, negative cuts).

q

Bandwidth parameter (higher Q = narrower peak).

void set_first_order_shelf(double sample_rate, double zero_hz, double pole_hz, double low_frequency_gain)

Configures this filter as a first-order shelf with independent zero and pole.

Both corners are prewarped separately, so a mirrored pair cancels exactly; see docs/archive/superpowers/specs/2026-09-05-dd3-spx90-design.md for the derivation.

Parameters

sample_rate

Sample rate in Hz.

zero_hz

Frequency of the transfer function's zero, in Hz.

pole_hz

Frequency of its pole, in Hz.

low_frequency_gain

Gain below both corners; 1.0 is unity.

float process_sample(float input)

Processes one sample through the filter.

Parameters

input

The input sample.

Returns

The filtered output sample.

void reset()

Clears the filter's internal state.

void set_coefficients(double b0, double b1, double b2, double a1, double a2)

Loads five coefficients computed elsewhere, leaving the state untouched.

Parameters

b0

Feed-forward tap on the current input, already divided by a0.

b1

Feed-forward tap on the previous input, already divided by a0.

b2

Feed-forward tap on the input before that, already divided by a0.

a1

Feedback tap on the previous output, already divided by a0.

a2

Feedback tap on the output before that, already divided by a0.

Precondition

|a2| < 1 and |a1| < 1 + a2, so the poles lie inside the unit circle.