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) — primordial sound, cosmic vibration. 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 interpolation (sinc in v0.22); 44.1k ↔ 48k ↔ 96k |
| DSP effects | Noise gate, hard limiter, compressor, normalize, EQ (biquad in v0.21) |
| Analysis | DFT spectrum, dominant frequency, LUFS loudness, silence detection |
| Transport clock | Sample-accurate position, tempo/beats, PTS timestamps for A/V sync |
| PipeWire capture | Per-source audio capture and output (feature-gated) |
| SIMD | SSE2/AVX2/NEON acceleration for mixing and DSP (v0.22) |
Quick start
[]
= "0.20"
use ;
use dsp;
use analysis;
use AudioClock;
// Create buffers
let vocals = from_interleaved?;
let drums = from_interleaved?;
// Mix
let mut mixed = mix?;
// Process
compress;
normalize;
noise_gate;
// Analyze
let spectrum = spectrum_dft;
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 |
|---|---|---|
simd |
Yes | SSE2/AVX2/NEON acceleration for mixing and DSP |
pipewire |
No | PipeWire audio capture/output backend |
full |
No | All features |
# Minimal (no system deps)
= { = "0.20", = false }
# 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
compress; // reduce dynamic range
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_dft;
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 (नाद — primordial sound) 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 | Foundation | Buffers, mix, resample, DSP, analysis, clock, 40+ tests |
| 0.21.3 | DSP & conversion | Biquad EQ, reverb, delay, format conversion, sinc resample |
| 0.22.3 | SIMD & capture | SSE2/AVX2/NEON mixing, PipeWire capture/output |
| 0.23.3 | Integration | shruti/jalwa/aethersafta adoption, rustfft, buffer pool |
| 1.0.0 | Stable API | Frozen types, 90%+ coverage, reference-quality DSP |
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.