Module biquad::coefficients
source[−]Expand description
coefficients
Module for generating filter coefficients for second order IIR biquads, where the coefficients form the following Z-domain transfer function:
b0 + b1 * z^-1 + b2 * z^-2
H(z) = --------------------------
1 + a1 * z^-1 + a2 * z^-2
The second orders filter are based on the Audio EQ Cookbook, while the first order low pass filter is based on the following Wikipedia article.
Examples
fn main() {
use biquad::*;
// Cutoff frequency
let f0 = 10.hz();
// Sampling frequency
let fs = 1.khz();
// Create coefficients
let coeffs = Coefficients::<f32>::from_params(Type::LowPass, fs, f0, Q_BUTTERWORTH_F32);
}
Errors
Coefficients::from_params(...)
can error if the cutoff frequency does not adhere to the
Nyquist Frequency, or if the Q value is
negative.
Structs
Holder of the biquad coefficients, utilizes normalized form
Enums
The supported types of biquad coefficients. Note that single pole low pass filters are faster to
retune, as all other filter types require evaluations of sin/cos functions
The LowShelf
, HighShelf
, and PeakingEQ
all have a gain value for its
field, and represents the gain, in decibels, that the filter provides.
Constants
Common Q value of the Butterworth low-pass filter