| Crates.io | biquad-filters-rust |
| lib.rs | biquad-filters-rust |
| version | 0.1.3 |
| created_at | 2025-03-22 22:51:58.950309+00 |
| updated_at | 2025-03-27 04:10:37.715656+00 |
| description | A digital biquad filter implementation |
| homepage | |
| repository | https://github.com/alex-parisi/biquad-filters |
| max_upload_size | |
| id | 1602177 |
| size | 85,048 |
This repository contains a collection of digital biquad filters implemented in Rust.
The filters are based off the C++ implementation, which can be found here.
For information on biquad filters, you can check out my website here.
To add the filters to your project, run the following Cargo command in your project directory:
cargo add biquad-filters-rust
Then, simply create an instance of a filter and process your data:
/// Import the biquad_filters crate
use biquad_filters::{Filter, LowPassFilter};
/// Define some dummy data to operate on
let n: usize = 100;
let mut samples: Vec<f64> = vec![0.0_f64; n];
/// Create the filter
/// This is a low-pass filter with a cutoff frequency at 1000 Hz,
/// a sample rate of 44100 Hz, and a Q factor of 0.707
let filter = LowPassFilter::<f64>::new(
1000.0_f64,
44100_u32,
std::f64::consts::FRAC_1_SQRT_2
).expect("Failed to create filter");
/// Process the data in-place
filter.process_block(&mut samples);
When using the filter's ::new function, it returns an Option so
you can check if the filter was created successfully.
f64 for the best
precision and to reduce the chance of encountering quantization noise. While
processing blocks of f32 samples will be faster, the precision of the
filter will be reduced.