embedded-dsp
A high-performance #![no_std] Rust Digital Signal Processing library designed for microcontrollers (Cortex-M, RISC-V, AVR, Xtensa), bare-metal DSP, and real-time audio/sensor pipelines.
Highlights
#![no_std]First: Purecorecompatibility with zero heap allocations.- Fixed & Float Parity: CMSIS-style
f32,f64, andq7/q15/q31— realfixedcrate types (I1F7/I1F15/I1F31), interoperable with the rest of the Rust fixed-point ecosystem — plus the polymorphicDspSampletrait. - Hardware Acceleration: ARM Cortex-M assembly intrinsics (
smlad,smlald,ssat,qadd16) viacortex-m-dsp, with portable SWAR vector fallbacks. - Pure-Integer CORDIC Engine: Shift-and-add
sin,cos,atan2, polar conversion, andsqrtrequiring no hardware multipliers. - Streaming Pipelines: Zero-allocation
DspNodecomposable processing chains (Chain,Gain,Limiter). - Production Tested: Continuous integration across 6 bare-metal architectures (
thumbv6m,thumbv7em,thumbv7em-hf,riscv32imc,wasm32,x86_64).
Module Overview
| Category | Key Algorithms & Structs |
|---|---|
| Filtering & Design | FIR, Biquad IIR (DF-I & Transposed DF-II), LMS/NLMS, Butterworth/Chebyshev design, Windowed-Sinc, $L_\infty/L_2$ SOS Quantization & SQNR analysis, DC Blocker. |
| Spectral & Transforms | CFFT, RFFT (packed), Block Floating-Point FFT (cfft_bfp_q15/q31), Real Cepstrum, DCT-IV, FWHT, Haar, Hartley, Daubechies-4 DWT, Welch & Burg AR PSD. |
| Audio & Voice | Goertzel tone detector, Mel & Generalized filterbanks, MFCC, Q15 VAD, Dynamics Compressor with soft knee, Noise Gate. |
| Control & Power | FOC current/speed PID, Clarke & Park transforms, SOGI-PLL (grid synchronization/resolvers), Costas Loop carrier recovery. |
| Sensor Fusion & Spatial | Square-Root Kalman Filter (SquareRootKalmanFilter), EKF, 2D Spatial/Vision (Sobel, Median, DCT-II), Delay-and-Sum Beamformer, GCC-PHAT TDoA locator. |
| Multi-rate & Resampling | CIC Decimator/Interpolator with bit-growth normalization, Polyphase Decimation & Interpolation (Float & Q15), fractional linear resampler. |
| Math, CORDIC & Windows | CORDIC engine, Complex math, Fast math, Quaternions (nalgebra interop), 9 Window functions (Kaiser-Bessel with $I_0(\beta)$, Flat-top), G.711 $\mu$-law/A-law companding. |
Quick Start
Add to your Cargo.toml:
[]
# Standard std environment (all modules enabled)
= "0.5.0"
# Bare-metal #![no_std] with libm
= { = "0.5.0", = false, = ["libm", "full"] }
# Minimal firmware footprint (only FIR/Biquad filtering + basic math)
= { = "0.5.0", = false, = ["libm", "filtering", "basic-math"] }
Basic Example
use *;
Cookbook & Examples
Need copy-paste code for real-world projects? Check the embedded-dsp Cookbook:
- Motor Control: Sensorless Field-Oriented Control (FOC) with Clarke/Park and Space-Vector PWM.
- Real-Time Audio DMA: DC-Blocker + Biquad Peaking EQ + Peak Limiter streaming pipeline.
- Machine Health: Vibration spectrum analysis and bearing fault detection using Burg AR PSD.
- Multi-rate ADC: High-speed Cascaded Integrator-Comb (CIC) decimation.
- Acoustic Edge AI: Voice Activity Detection (VAD) & MFCC feature extraction.
- Streaming Pipeline: Composing modular
DspNodesignal processing chains.
Run any included example directly with cargo:
License
Dual-licensed under either MIT or Apache-2.0 at your option. See LICENSE-MIT and LICENSE-APACHE.