#filter #iir #biquad

iir_filters

A Rust re-implementation of some of scipy's digital filters

4 releases

0.1.3 Oct 16, 2023
0.1.2 Aug 22, 2022
0.1.1 Aug 20, 2022
0.1.0 Aug 19, 2022

#267 in Audio

Download history 3/week @ 2024-06-24 8/week @ 2024-07-15 44/week @ 2024-07-22 12/week @ 2024-07-29 4/week @ 2024-08-05 16/week @ 2024-08-19 4/week @ 2024-08-26 3/week @ 2024-09-02 22/week @ 2024-09-23 13/week @ 2024-09-30 16/week @ 2024-10-07

51 downloads per month

Apache-2.0

1.5MB
2K SLoC

iir_filters

A Rust re-implementation of some of scipy's digital filters.

Example:

use iir_filters::filter_design::FilterType;
use iir_filters::filter_design::butter;
use iir_filters::sos::zpk2sos;
use iir_filters::filter::DirectForm2Transposed;
use iir_filters::filter::Filter;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let order = 5;
    let cutoff_low = 1.0;
    let cutoff_hi= 10.0;
    let fs = 81.0;

    let zpk = butter(order, FilterType::BandPass(cutoff_low, cutoff_hi),fs)?;
    let sos = zpk2sos(&zpk, None)?;

    let mut dft2 = DirectForm2Transposed::new(&sos);
    
    let input:Vec<f64>  = vec![1.0, 2.0, 3.0];
    let mut output:Vec<f64> = vec![];
    
    for x in input.iter() {
        output.push( dft2.filter(*x) );
    }
    
    return Ok( () );
}

See: scipy.signal: butter()

⚠️ For now it only implements Butterworth filters, because that's all I'm interested in.

Dependencies