Skip to content

Commit

Permalink
doc: fix doc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SolarLiner committed Mar 5, 2024
1 parent 01becca commit a9a1279
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
11 changes: 7 additions & 4 deletions src/filters/biquad.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
//! Transposed Direct Form II Biquad implementation
//!
//!
//! Nonlinearities based on <https://jatinchowdhury18.medium.com/complex-nonlinearities-episode-5-nonlinear-feedback-filters-115e65fc0402>
//!
//!
//! # 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::<f32, Tanh>::lowpass(0.25 /* normalized frequency */, 0.707 /* Q */);
//! let output = lowpass.process([0.0]);
//! ```

Expand Down
9 changes: 6 additions & 3 deletions src/filters/ladder.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
//! Implementation of various blocks of DSP code from the VA Filter Design book.
//!
//!
//! Downloaded from <https://www.discodsp.net/VAFilterDesign_2.1.2.pdf>
//!
//!
//! # Example
//!
//!
//! ```rust
//! use valib::dsp::DSP;
//! use valib::filters::ladder::{Ladder, OTA};
//! use valib::saturators::Tanh;
//! let mut filter = Ladder::<f32, OTA<Tanh>>::new(44100.0, 300.0, 0.5);
//! let output = filter.process([0.0]);
//! ```
Expand Down
29 changes: 16 additions & 13 deletions src/filters/statespace.rs
Original file line number Diff line number Diff line change
@@ -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<f32, 1, 1, 1> {
//! 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]);
//! ```
Expand Down

0 comments on commit a9a1279

Please sign in to comment.