idsp

Struct Cic

Source
pub struct Cic<T, const N: usize> { /* private fields */ }
Expand description

Cascaded integrator comb structure

Order N where N = 3 is cubic.

Implementations§

Source§

impl<T, const N: usize> Cic<T, N>
where T: Num + AddAssign + WrappingAdd + WrappingSub + Pow<usize, Output = T> + Copy + 'static, u32: AsPrimitive<T>,

Source

pub fn new(rate: u32) -> Self

Create a new zero-initialized filter with the given rate change.

Source

pub const fn order(&self) -> usize

Filter order

  • 0: zero order hold
  • 1: linear
  • 2: quadratic
  • 3: cubic interpolation/decimation

etc.

Source

pub const fn rate(&self) -> u32

Rate change

fast/slow - 1

Source

pub fn set_rate(&mut self, rate: u32)

Set the rate change

fast/slow - 1

Source

pub fn clear(&mut self)

Zero-initialize the filter state

Source

pub const fn tick(&self) -> bool

Accepts/provides new slow-rate sample

Interpolator: accepts new input sample Decimator: returns new output sample

Source

pub fn get_interpolate(&self) -> T

Current interpolator output

Source

pub fn get_decimate(&self) -> T

Current decimator output

Source

pub fn gain(&self) -> T

Filter gain

Source

pub const fn gain_log2(&self) -> u32

Right shift amount

log2(gain()) if gain is a power of two, otherwise an upper bound.

Source

pub const fn response_length(&self) -> usize

Impulse response length

Source

pub fn settle_interpolate(&mut self, x: T)

Establish a settled filter state

Source

pub fn settle_decimate(&mut self, x: T)

Establish a settled filter state

Unimplemented!

Source

pub fn interpolate(&mut self, x: Option<T>) -> T

Optionally ingest a new low-rate sample and retrieve the next output.

A new sample must be supplied at the correct time (when Cic::tick() is true)

Source

pub fn decimate(&mut self, x: T) -> Option<T>

Ingest a new high-rate sample and optionally retrieve next output.

Trait Implementations§

Source§

impl<T: Clone, const N: usize> Clone for Cic<T, N>

Source§

fn clone(&self) -> Cic<T, 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<T: Debug, const N: usize> Debug for Cic<T, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for Cic<T, N>
where T: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for Cic<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Send for Cic<T, N>
where T: Send,

§

impl<T, const N: usize> Sync for Cic<T, N>
where T: Sync,

§

impl<T, const N: usize> Unpin for Cic<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for Cic<T, N>
where T: UnwindSafe,

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

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