weirdnet-dsp
Small, dependency-free DSP building blocks for Weirdnet audio crates, by Weird Brains. Pure functions and small state structs over f32 slices: no I/O, no audio types, no allocation in the per-block paths.
level: dB and linear conversion, peak and RMS.fade: linear and equal-power fades in place on interleaved audio.biquad: RBJ-cookbook biquads (low-pass, high-pass, band-pass, peaking) designed from a cutoff, Q and gain, with the exact frequency response (BiquadCoeffs::response_db) so a filter can be checked against its design.Biquadfilters one channel;MultiBiquadfilters interleaved audio with one state per channel.resample: streaming sample-rate conversion.Resampler::new(from, to, channels)andprocess(input, output)on interleaved slices, with no allocation afternew; the output does not depend on how the input is cut, and a 1:1 ratio passes samples through unchanged. A windowed-sinc kernel (16 zero crossings each side under a Blackman-Harris window, cut off at the lower Nyquist frequency) keeps a 1 kHz tone within 0.002 of the ideal from 44.1 to 48 kHz and back and from 48 to 96 kHz and back, and a 30 kHz tone more than 40 dB down when going from 96 to 48 kHz.set_trimmoves the ratio by up to 1 % to follow another device's clock.stretch(cargo featurestretch, off by default):time_stretchto an exact number of frames andpitch_shiftover interleaved audio, on the Signalsmith Stretch library (MIT). It builds C++ with bindgen, so it needs clang and libclang.
use ;
let coeffs = design?;
let mut filter = new; // stereo
let mut block = vec!; // interleaved
filter.process_interleaved;
# Ok::
Designing a filter is checked: a zero sample rate, a cutoff at or above the Nyquist frequency, a non-positive Q and non-finite values are errors, not silent garbage.
Rust 1.99 or newer, edition 2024. BSD-3-Clause, Copyright (c) 2026, Weird Brains LLC.