Crate lowpass_filter

Source
Expand description

Simple first-order digital lowpass filters, compatible with no_std. You can use it, for example, to get the low frequencies from a song.

§Difference to biquad

⚠ TL;DR: biquad might be a better option in some use-cases.

This crate provides a basic and simple to understand, first order lowpass filter. The biquad crate offers second order filters, with higher accuracy. From my testing, a lowpass filter created with biquad has higher computational costs as this crate, but offers a better resolution for actually cutting of signals above the cut-off frequency while the preserved signal will be less attenuated.

So for production use-cases, please also consider using biquad. You can run benchmark and check your data (e.g., by plotting) to make that decision.

§Usage

You can either use the LowpassFilter type to integrate the filter in iterator chains or you can use a convenient function such as lowpass_filter and lowpass_filter_f64. The first approach is more flexible.

§Example with LowpassFilter type

See implementation of lowpass_filter.

§Example with lowpass_filter function

use lowpass_filter::lowpass_filter;

// some samples
let mut mono_audio_data = [0.0, 1.0, -5.0, 1551.0, 141.0, 24.0];
// mutates the input buffer
lowpass_filter(&mut mono_audio_data, 44100.0, 120.0);

Structs§

LowpassFilter
A single-order lowpass filter with single precision that consumes and emits items one by one.

Functions§

lowpass_filter
Applies a LowpassFilter to the data provided in the mutable buffer and changes the items in-place.
lowpass_filter_f64
Applies a LowpassFilter to the data provided in the mutable buffer and changes the items in-place.