Skip to main content

weirdnet_dsp/
lib.rs

1//! Weirdnet DSP building blocks. Pure functions and small state machines over `f32` slices: no I/O, no allocation in the
2//! per-block paths ([`Biquad::process`], [`MultiBiquad::process_interleaved`], the fades and the level helpers).
3//!
4//! * [`level`]: dB and linear conversion, peak and RMS.
5//! * [`fade`]: fade curves and in-place fades on interleaved audio.
6//! * `stretch` (feature `stretch`): time stretch and pitch shift over Signalsmith Stretch.
7//! * [`biquad`]: RBJ-cookbook biquad filters (low-pass, high-pass, band-pass, peaking) with a frequency-response check.
8//! * [`resample`]: streaming sample-rate conversion (windowed sinc) with a fine ratio trim for following another clock.
9//!
10//! ```
11//! use weirdnet_dsp::{BiquadCoeffs, FilterKind, MultiBiquad};
12//!
13//! let coeffs = BiquadCoeffs::design(FilterKind::LowPass, 48_000, 1_000.0, std::f64::consts::FRAC_1_SQRT_2, 0.0)?;
14//! let mut filter = MultiBiquad::new(2, coeffs); // stereo, interleaved
15//! let mut block = vec![0.0f32; 512];
16//! filter.process_interleaved(&mut block);
17//! # Ok::<(), weirdnet_dsp::DspError>(())
18//! ```
19
20pub mod biquad;
21pub mod fade;
22pub mod level;
23pub mod resample;
24#[cfg(feature = "stretch")]
25pub mod stretch;
26
27pub use biquad::{Biquad, BiquadCoeffs, DspError, FilterKind, MultiBiquad};
28pub use fade::{FadeCurve, fade_in, fade_out};
29pub use level::{db_to_linear, linear_to_db, peak, rms};