Module biquad::coefficients[][src]

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::new(Type::LowPass, fs, f0, Q_BUTTERWORTH);
}

Errors

Coefficients::new(...) can error if the cutoff frequency does not adhere to the Nyquist Frequency, or if the Q value is negative.

Structs

Coefficients

Holder of the biquad coefficients, utilizes normalized form

Enums

Type

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

Constants

Q_BUTTERWORTH

Common Q value of the Butterworth low-pass filter