dhvani
Core audio engine for Rust.
Buffers, DSP, resampling, mixing, analysis, and capture — in a single crate. The audio equivalent of ranga (image processing) and tarang (media framework).
Name: Dhvani (ध्वनि, Sanskrit) — sound, resonance. Extracted from shruti (DAW) as a standalone, reusable engine.
What it does
dhvani is the audio processing core — it owns the audio math so nobody else has to. Applications build their audio features on top of dhvani.
| Capability | Details |
|---|---|
| Audio buffers | Unified AudioBuffer type — f32 interleaved, channel-aware, sample-rate-aware |
| Mixing | Sum N sources with channel/rate validation |
| Resampling | Linear + sinc (Blackman-Harris window); 44.1k ↔ 48k ↔ 96k |
| DSP effects | Biquad EQ, compressor, limiter, reverb, delay, de-esser, panner, noise gate, normalize |
| Analysis | FFT spectrum, STFT, EBU R128 loudness, dynamics, chromagram, onset detection |
| MIDI | MIDI 1.0/2.0, voice management, clip operations, routing |
| Transport clock | Sample-accurate position, tempo/beats, PTS timestamps for A/V sync |
| Audio graph | RT-safe graph with topological execution and double-buffered plan swap |
| PipeWire capture | Per-source audio capture and output (feature-gated) |
| SIMD | SSE2/AVX2/NEON acceleration for mixing, gain, clamp, peak, RMS |
Quick start
[]
= "0.20"
use ;
use ;
use analysis;
use AudioClock;
// Create buffers
let vocals = from_interleaved?;
let drums = from_interleaved?;
// Mix
let mut mixed = mix?;
// Process
let mut comp = new?;
comp.process;
normalize;
noise_gate;
// Analyze
let spectrum = spectrum_fft.unwrap;
let loudness = loudness_lufs;
println!;
// Resample for output
let output = resample_linear?;
// Sync with video via clock
let mut clock = new;
clock.start;
clock.advance;
println!;
Features
| Flag | Default | Description |
|---|---|---|
dsp |
Yes | DSP effects (EQ, compressor, limiter, reverb, delay, de-esser, panner, oscillator, LFO, envelope) |
analysis |
Yes | Audio analysis (FFT, STFT, R128 loudness, dynamics, chromagram, onset detection). Implies dsp |
midi |
Yes | MIDI 1.0/2.0 events, voice management, routing, translation |
graph |
Yes | RT-safe audio graph, lock-free metering |
simd |
Yes | SSE2/AVX2/NEON acceleration for mixing, gain, peak, RMS, format conversion |
pipewire |
No | PipeWire audio capture/output backend (Linux only) |
full |
No | All features including PipeWire |
# Everything (default)
= "0.20"
# Core only — buffers, mixing, resampling, clock (no DSP/MIDI/analysis/graph)
= { = "0.20", = false }
# Media player — DSP + analysis, no MIDI or graph
= { = "0.20", = false, = ["dsp", "analysis", "simd"] }
# With PipeWire capture (Linux)
= { = "0.20", = ["pipewire"] }
Key types
AudioBuffer
Core sample buffer. Holds f32 interleaved samples with channel count and sample rate.
let mut buf = silence; // 1 second stereo
buf.apply_gain;
buf.clamp;
println!;
AudioClock
Sample-accurate transport with tempo awareness and PTS generation for A/V sync.
let mut clock = with_tempo; // 120 BPM
clock.start;
clock.advance; // 1 second
println!;
DSP
noise_gate; // silence below threshold
hard_limiter; // prevent clipping
normalize; // peak normalize
let db = amplitude_to_db; // -6.02 dB
let amp = db_to_amplitude; // ~0.501
Analysis
let spectrum = spectrum_fft.unwrap;
if let Some = spectrum.dominant_frequency
let lufs = loudness_lufs;
let silent = is_silent;
The Sanskrit Stack
shruti (श्रुति — that which is heard) creates music
└── with dhvani (ध्वनि — sound, resonance) as its audio engine
└── carried by tarang (तरंग — wave) as its media framework
└── colored by ranga (रंग — color) for visual processing
Who uses this
| Project | Usage |
|---|---|
| shruti | DAW — all audio math (mix, DSP, analysis, transport) |
| jalwa | Media player — playback EQ, spectrum visualizer, resampling |
| aethersafta | Compositor — PipeWire capture, audio mixing for streams |
| tarang | Media framework — audio analysis, fingerprint input |
| hoosh | Inference gateway — audio preprocessing for whisper STT |
Roadmap
| Version | Milestone | Key features |
|---|---|---|
| 0.20.3 | Complete engine | Buffers, DSP (EQ/reverb/compressor/delay), MIDI 1.0/2.0, SIMD, FFT, R128, graph, PipeWire, 265+ tests |
| 0.21.3 | Hardening & API freeze | Safety comments on all unsafe, API encapsulation, 24-bit/f64/u8 formats, panic elimination, buffer pool |
| 0.22.3 | Testing, SIMD & adoption | SIMD completeness (AVX2/NEON gaps), 90%+ coverage, docs.rs, consumer integration, golden benchmarks |
| 1.0.0 | Stable | Frozen API, 3+ consumers, reference-quality DSP, full platform parity |
Full details: docs/development/roadmap.md
Building from source
# Build (no system deps needed)
# Build with PipeWire (Linux, requires libpipewire-dev)
# Run tests
# Run benchmarks
# Run all CI checks locally
Versioning
Pre-1.0 releases use 0.D.M (day.month) SemVer — e.g. 0.20.3 = March 20th.
Post-1.0 follows standard SemVer.
License
AGPL-3.0-only. See LICENSE for details.