pub struct Lowpass<const N: usize>(/* private fields */);Expand description
Arbitrary order, high dynamic range, wide coefficient range, lowpass filter implementation. DC gain is 1.
Type argument N is the filter order. N must be 1 or 2.
The filter will cleanly saturate towards the i32 range.
Both filters have been optimized for accuracy, dynamic range, and speed on Cortex-M7.
Trait Implementations§
Source§impl<const N: usize> Filter for Lowpass<N>
impl<const N: usize> Filter for Lowpass<N>
Source§type Config = [i32; N]
type Config = [i32; N]
The filter configuration Config contains the filter gains.
For the first-order lowpass this is a single element array [k] with
the corner frequency in scaled Q31:
k = pi*(1 << 31)*f0/fn where
f0 is the 3dB corner frequency and
fn is the Nyquist frequency.
The corner frequency is warped in the usual way.
For the second-order lowpass this is [k**2/(1 << 32), -k/q] with q = 1/sqrt(2)
for a Butterworth response.
In addition to the poles at the corner frequency the filters have zeros at Nyquist.
The first-order lowpass works fine and accurate for any positive gain
1 <= k <= (1 << 31) - 1.
The second-order lowpass works and is accurate for
1 << 16 <= k <= q*(1 << 31).