Git Product home page Git Product logo

biquad-rs's Introduction

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));
    }
}

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.

biquad-rs's People

Contributors

korken89 avatar a2aaron avatar eriknatanael avatar fhennig avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.