#signal-processing #filter #iir #forms #digital-signal-processing #direct #order

no-std biquad

A library for digital second order IIR filtrers, also known as biquads

7 unstable releases

0.4.2 Jan 14, 2022
0.4.1 Apr 22, 2021
0.4.0 Jan 16, 2021
0.3.1 Apr 10, 2020
0.1.0 Jul 24, 2018

#600 in Embedded development

Download history 513/week @ 2024-07-22 405/week @ 2024-07-29 568/week @ 2024-08-05 472/week @ 2024-08-12 592/week @ 2024-08-19 452/week @ 2024-08-26 494/week @ 2024-09-02 429/week @ 2024-09-09 590/week @ 2024-09-16 473/week @ 2024-09-23 594/week @ 2024-09-30 315/week @ 2024-10-07 476/week @ 2024-10-14 366/week @ 2024-10-21 387/week @ 2024-10-28 431/week @ 2024-11-04

1,693 downloads per month
Used in 13 crates (9 directly)

MIT/Apache

40KB
873 lines

biquad

Build Status

biquad is a #![no_std] library for creating first and second order IIR filters for signal processing based on Biquads. Both a Direct Form 1 (DF1) and Direct Form 2 Transposed (DF2T) implementation is available, where the DF1 is better used when the filter needs retuning online, as it has the property to introduce minimal artifacts under retuning, while the DF2T is best used for static filters as it has the least computational complexity and best numerical stability.

This crate implements the biquads for f32 and f64.

Example

fn main() {
    use biquad::*;

    // Cutoff and sampling frequencies
    let f0 = 10.hz();
    let fs = 1.khz();

    // Create coefficients for the biquads
    let coeffs = Coefficients::<f32>::from_params(Type::LowPass, fs, f0, Q_BUTTERWORTH_F32).unwrap();

    // Create two different biquads
    let mut biquad1 = DirectForm1::<f32>::new(coeffs);
    let mut biquad2 = DirectForm2Transposed::<f32>::new(coeffs);

    let input_vec = vec![0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
    let mut output_vec1 = Vec::new();
    let mut output_vec2 = Vec::new();

    // Run for all the inputs
    for elem in input_vec {
        output_vec1.push(biquad1.run(elem));
        output_vec2.push(biquad2.run(elem));
    }
}

Documentation

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~420KB