LMMS
Loading...
Searching...
No Matches
dsp::biquad_coeffs Class Reference

#include <biquad.h>

Inheritance diagram for dsp::biquad_coeffs:
dsp::biquad_d1 dsp::biquad_d1_lerp dsp::biquad_d2

Public Types

typedef std::complex< double > cfloat

Public Member Functions

 biquad_coeffs ()
void set_null ()
void set_lp_rbj (float fc, float q, float sr, float gain=1.0)
void set_lp_zoelzer (float fc, float q, float odsr, float gain=1.0)
void set_hp_rbj (float fc, float q, float esr, float gain=1.0)
void set_hp_rbj_optimized (float fc, float q, float esr, float gain=1.0)
void set_bp_rbj (double fc, double q, double esr, double gain=1.0)
void set_br_rbj (double fc, double q, double esr, double gain=1.0)
void set_allpass (float freq, float pole_r, float sr)
void set_bilinear (double aa0, double aa1, double aa2, double ab0, double ab1, double ab2)
 set digital filter parameters based on given analog filter parameters
void set_bilinear_direct (double aa0, double aa1, double aa2, double ab1, double ab2)
 set digital filter parameters directly
void set_peakeq_rbj (double freq, double q, double peak, double sr)
void set_lowshelf_rbj (float freq, float q, float peak, float sr)
void set_highshelf_rbj (float freq, float q, float peak, float sr)
void copy_coeffs (const biquad_coeffs &src)
 copy coefficients from another biquad
float freq_gain (float freq, float sr) const
cfloat h_z (const cfloat &z) const

Static Public Member Functions

static double prewarp (float freq, float sr)
 prewarping for bilinear transform, maps given digital frequency to analog counterpart for analog filter design
static double unwarp (float omega, float sr)
 convert analog angular frequency value to digital
static double unwarpf (float t, float sr)
 convert analog filter time constant to digital counterpart

Public Attributes

double a0
double a1
double a2
double b1
double b2

Detailed Description

Coefficients for two-pole two-zero filter, for floating point values, plus a bunch of functions to set them to typical values.

Coefficient calculation is based on famous Robert Bristow-Johnson's equations, except where it's not. The coefficient calculation is NOT mine, the only exception is the lossy optimization in Zoelzer and rbj HP filter code.

See http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt for reference.

don't use this for integers because it won't work

Member Typedef Documentation

◆ cfloat

Constructor & Destructor Documentation

◆ biquad_coeffs()

dsp::biquad_coeffs::biquad_coeffs ( )
inline

Member Function Documentation

◆ copy_coeffs()

void dsp::biquad_coeffs::copy_coeffs ( const biquad_coeffs & src)
inline

copy coefficients from another biquad

◆ freq_gain()

float dsp::biquad_coeffs::freq_gain ( float freq,
float sr ) const
inline

Return the filter's gain at frequency freq

Parameters
freqFrequency to look up
srFilter sample rate (used to convert frequency to angular frequency)

◆ h_z()

cfloat dsp::biquad_coeffs::h_z ( const cfloat & z) const
inline

Return H(z) the filter's gain at frequency freq

Parameters
zZ variable (e^jw)

◆ prewarp()

double dsp::biquad_coeffs::prewarp ( float freq,
float sr )
inlinestatic

prewarping for bilinear transform, maps given digital frequency to analog counterpart for analog filter design

◆ set_allpass()

void dsp::biquad_coeffs::set_allpass ( float freq,
float pole_r,
float sr )
inline

◆ set_bilinear()

void dsp::biquad_coeffs::set_bilinear ( double aa0,
double aa1,
double aa2,
double ab0,
double ab1,
double ab2 )
inline

set digital filter parameters based on given analog filter parameters

◆ set_bilinear_direct()

void dsp::biquad_coeffs::set_bilinear_direct ( double aa0,
double aa1,
double aa2,
double ab1,
double ab2 )
inline

set digital filter parameters directly

◆ set_bp_rbj()

void dsp::biquad_coeffs::set_bp_rbj ( double fc,
double q,
double esr,
double gain = 1.0 )
inline

Bandpass filter based on Robert Bristow-Johnson's equations (normalized to 1.0 at center frequency)

Parameters
fccenter frequency (gain at fc = 1.0)
q=~ fc/bandwidth (not quite, but close) - 1/Q = 2*sinh(ln(2)/2*BW*w0/sin(w0))
srsample rate
gainamplification (gain at sr/2)

◆ set_br_rbj()

void dsp::biquad_coeffs::set_br_rbj ( double fc,
double q,
double esr,
double gain = 1.0 )
inline

◆ set_highshelf_rbj()

void dsp::biquad_coeffs::set_highshelf_rbj ( float freq,
float q,
float peak,
float sr )
inline

RBJ high shelf EQ - amplitication of 0dB at 0 Hz and of peak at sr/2 Hz

Parameters
freqcorner frequency (gain at freq is sqrt(peak))
qq (relates bandwidth and peak frequency), the higher q, the louder the resonant peak (situated above fc) is
peakshelf gain (1.0 means no peak, >1.0 means a peak, less than 1.0 is a dip)

◆ set_hp_rbj()

void dsp::biquad_coeffs::set_hp_rbj ( float fc,
float q,
float esr,
float gain = 1.0 )
inline

Highpass filter based on Robert Bristow-Johnson's equations

Parameters
fcresonant frequency
qresonance (gain at fc)
srsample rate
gainamplification (gain at sr/2)

◆ set_hp_rbj_optimized()

void dsp::biquad_coeffs::set_hp_rbj_optimized ( float fc,
float q,
float esr,
float gain = 1.0 )
inline

◆ set_lowshelf_rbj()

void dsp::biquad_coeffs::set_lowshelf_rbj ( float freq,
float q,
float peak,
float sr )
inline

RBJ low shelf EQ - amplitication of 'peak' at 0 Hz and of 1.0 (0dB) at sr/2 Hz

Parameters
freqcorner frequency (gain at freq is sqrt(peak))
qq (relates bandwidth and peak frequency), the higher q, the louder the resonant peak (situated below fc) is
peakshelf gain (1.0 means no peak, >1.0 means a peak, less than 1.0 is a dip)

◆ set_lp_rbj()

void dsp::biquad_coeffs::set_lp_rbj ( float fc,
float q,
float sr,
float gain = 1.0 )
inline

Lowpass filter based on Robert Bristow-Johnson's equations Perhaps every synth code that doesn't use SVF uses these equations :)

Parameters
fcresonant frequency
qresonance (gain at fc)
srsample rate
gainamplification (gain at 0Hz)

◆ set_lp_zoelzer()

void dsp::biquad_coeffs::set_lp_zoelzer ( float fc,
float q,
float odsr,
float gain = 1.0 )
inline

◆ set_null()

void dsp::biquad_coeffs::set_null ( )
inline

◆ set_peakeq_rbj()

void dsp::biquad_coeffs::set_peakeq_rbj ( double freq,
double q,
double peak,
double sr )
inline

RBJ peaking EQ

Parameters
freqpeak frequency
qq (correlated to freq/bandwidth,
See also
set_bp_rbj)
Parameters
peakpeak gain (1.0 means no peak, >1.0 means a peak, less than 1.0 is a dip)

◆ unwarp()

double dsp::biquad_coeffs::unwarp ( float omega,
float sr )
inlinestatic

convert analog angular frequency value to digital

◆ unwarpf()

double dsp::biquad_coeffs::unwarpf ( float t,
float sr )
inlinestatic

convert analog filter time constant to digital counterpart

Member Data Documentation

◆ a0

double dsp::biquad_coeffs::a0

◆ a1

double dsp::biquad_coeffs::a1

◆ a2

double dsp::biquad_coeffs::a2

◆ b1

double dsp::biquad_coeffs::b1

◆ b2

double dsp::biquad_coeffs::b2

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