diff --git a/src/filters/biquad.rs b/src/filters/biquad.rs index 987dc79..7ea71e1 100644 --- a/src/filters/biquad.rs +++ b/src/filters/biquad.rs @@ -1,11 +1,14 @@ //! Transposed Direct Form II Biquad implementation -//! +//! //! Nonlinearities based on -//! +//! //! # Usage -//! +//! //! ```rust -//! let mut lowpass = Biquad::lowpass(0.25 /* normalized frequency */, 0.707 /* Q */); +//! use valib::dsp::DSP; +//! use valib::filters::biquad::Biquad; +//! use valib::saturators::Tanh; +//! let mut lowpass = Biquad::::lowpass(0.25 /* normalized frequency */, 0.707 /* Q */); //! let output = lowpass.process([0.0]); //! ``` diff --git a/src/filters/ladder.rs b/src/filters/ladder.rs index c2decc9..1e195d6 100644 --- a/src/filters/ladder.rs +++ b/src/filters/ladder.rs @@ -1,10 +1,13 @@ //! Implementation of various blocks of DSP code from the VA Filter Design book. -//! +//! //! Downloaded from -//! +//! //! # Example -//! +//! //! ```rust +//! use valib::dsp::DSP; +//! use valib::filters::ladder::{Ladder, OTA}; +//! use valib::saturators::Tanh; //! let mut filter = Ladder::>::new(44100.0, 300.0, 0.5); //! let output = filter.process([0.0]); //! ``` diff --git a/src/filters/statespace.rs b/src/filters/statespace.rs index 53b2b50..f470f03 100644 --- a/src/filters/statespace.rs +++ b/src/filters/statespace.rs @@ -1,21 +1,24 @@ //! Linear state-space model implementation for arbitrary I/O. -//! +//! //! # Example -//! +//! //! ```rust -//! fn create_filter(fc: T) -> Self { +//! use nalgebra::SMatrix; +//! use valib::dsp::DSP; +//! use valib::filters::statespace::StateSpace; +//! use valib::Scalar; +//! +//! /// Implements a 1-pole lowpass filter as a linear state-space model +//! fn create_filter(fc: f32) -> StateSpace { //! let new = SMatrix::<_, 1, 1>::new; -//! // Implementes a 1-pole lowpass filter with the given normalized frequency as -//! // cutoff. -//! Self(StateSpace { -//! a: new(-(fc - 2.0) / (fc + 2.0)), -//! b: new(1.0), -//! c: new(-fc * (fc - 2.0) / (fc + 2.0).simd_powi(2) + fc / (fc + 2.0)), -//! d: new(fc / (fc + 2.0)), -//! ..StateSpace::zeros() -//! }) +//! StateSpace ::new( +//! new(-(fc - 2.0) / (fc + 2.0)), +//! new(1.0), +//! new(-fc * (fc - 2.0) / (fc + 2.0).powi(2) + fc / (fc + 2.0)), +//! new(fc / (fc + 2.0)), +//! ) //! } -//! +//! //! let mut filter = create_filter(0.25); //! let output = filter.process([0.0]); //! ```