Crates.io | iir_filters |
lib.rs | iir_filters |
version | 0.1.3 |
source | src |
created_at | 2022-08-19 14:42:57.743919 |
updated_at | 2023-10-16 13:45:53.6889 |
description | A Rust re-implementation of some of scipy's digital filters. |
homepage | |
repository | https://github.com/annoybot/iir_filters |
max_upload_size | |
id | 648737 |
size | 3,913,948 |
A Rust re-implementation of some of scipy's digital filters.
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( () );
}
⚠️ For now it only implements Butterworth filters, because that's all I'm interested in.