Struct idsp::Lowpass

source ·
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> Clone for Lowpass<N>

source§

fn clone(&self) -> Lowpass<N>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<const N: usize> Default for Lowpass<N>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<const N: usize> Filter for Lowpass<N>

source§

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).

source§

fn update(&mut self, x: i32, k: &Self::Config) -> i32

Update the filter with a new sample. Read more
source§

fn get(&self) -> i32

Return the current filter output
source§

fn set(&mut self, x: i32)

Update the filter so that it outputs the provided value. This does not completely define the state of the filter.
source§

impl<const N: usize> Copy for Lowpass<N>

Auto Trait Implementations§

§

impl<const N: usize> Freeze for Lowpass<N>

§

impl<const N: usize> RefUnwindSafe for Lowpass<N>

§

impl<const N: usize> Send for Lowpass<N>

§

impl<const N: usize> Sync for Lowpass<N>

§

impl<const N: usize> Unpin for Lowpass<N>

§

impl<const N: usize> UnwindSafe for Lowpass<N>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.