dhvani
Core audio engine for Rust.
Buffers, DSP, resampling, mixing, analysis, synthesis, and capture — in a single crate. The audio equivalent of ranga (image processing) and tarang (media framework).
Name: Dhvani (ध्वनि, Sanskrit) — sound, resonance.
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 | AudioBuffer — f32 interleaved, channel-aware, sample-rate-aware, buffer pool |
| Mixing | Sum N sources with channel/rate validation |
| Resampling | Linear + sinc (Blackman-Harris window, Draft/Good/Best quality) |
| Format conversion | i16, i24, i32, f32, f64, u8 with roundtrip fidelity; dithering (TPDF + noise-shaped) |
| DSP effects | Biquad EQ, SVF filter, parametric/graphic EQ, compressor, limiter, reverb, convolution reverb, delay, de-esser, panner, noise gate, automation curves, routing matrix |
| Analysis | FFT spectrum, STFT, EBU R128 loudness, dynamics (true peak), chromagram, onset/beat/key detection |
| Synthesis | Subtractive, FM, additive, wavetable, granular, physical modeling, drum, vocoder, sampler (via naad/nidhi) |
| Voice synthesis | Glottal source, formant filtering, phoneme sequencing, prosody (via svara) |
| Acoustics | Room IR generation, convolution/FDN reverb, ambisonics decode, room presets (via goonj) |
| MIDI | MIDI 1.0/2.0, voice management, clip operations, routing, translation |
| Transport clock | Sample-accurate position, tempo/beats, PTS timestamps for A/V sync |
| Audio graph | RT-safe graph with topological execution, latency compensation, double-buffered plan swap |
| Metering | Lock-free peak/RMS/LUFS metering via atomics, peak hold with decay |
| PipeWire capture | Device enumeration, per-source capture, output, hot-plug detection |
| SIMD | SSE2/AVX2/NEON acceleration — mixing, gain, clamp, peak, RMS, format conversion, biquad stereo |
Quick start
[]
= "1"
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;
// Analyze
let spectrum = spectrum_fft?;
let r128 = measure_r128?;
println!;
// Resample for output
let output = resample_linear?;
Features
| Flag | Default | Description |
|---|---|---|
dsp |
Yes | DSP effects (EQ, compressor, limiter, reverb, convolution, delay, de-esser, panner, oscillator, LFO, envelope, SVF, automation, routing) |
analysis |
Yes | Audio analysis (FFT, STFT, R128 loudness, dynamics, chromagram, onset/beat/key 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 |
synthesis |
No | Synthesis engines via naad |
voice |
No | Voice synthesis via svara. Implies synthesis |
creature |
No | Creature/animal vocals via prani. Implies synthesis |
environment |
No | Environmental sounds via garjan. Implies synthesis |
mechanical |
No | Mechanical sounds via ghurni. Implies synthesis |
sampler |
No | Sample playback via nidhi |
acoustics |
No | Room acoustics via goonj. Implies analysis |
g2p |
No | Grapheme-to-phoneme via shabda. Implies voice |
bhava-voice |
No | Personality/mood to voice mapping via bhava. Implies voice |
pipewire |
No | PipeWire audio capture/output (Linux) |
parallel |
No | Parallel graph execution via rayon. Implies graph |
full |
No | All features |
# Everything (default: dsp + analysis + midi + graph + simd)
= "1"
# Core only — buffers, mixing, resampling, clock
= { = "1", = false }
# Media player — DSP + analysis, no MIDI or graph
= { = "1", = false, = ["dsp", "analysis", "simd"] }
# Full synthesis + acoustics
= { = "1", = ["full"] }
Architecture
dhvani
├── buffer/ AudioBuffer, format conversion, mixing, resampling, dithering
├── clock/ Sample-accurate transport, tempo, beats, PTS
├── dsp/ Biquad, SVF, EQ, compressor, limiter, reverb, convolution, delay, automation, routing
├── analysis/ FFT, STFT, R128 loudness, dynamics, chromagram, onset/beat/key detection
├── midi/ MIDI 1.0/2.0, voice management, clips, routing, translation
├── graph/ RT-safe audio graph, topological execution, latency compensation
├── meter/ Lock-free peak/RMS/LUFS metering
├── capture/ PipeWire capture/output, device enumeration
├── simd/ SSE2/AVX2/NEON kernels with scalar fallback
├── synthesis/ Synth engines via naad (subtractive, FM, additive, wavetable, granular, drum, vocoder)
├── voice_synth/ Voice synthesis via svara (glottal, formant, phoneme, prosody)
├── acoustics/ Room acoustics via goonj (IR generation, convolution, FDN, ambisonics, presets)
├── creature/ Animal vocals via prani
├── environment/ Nature sounds via garjan
├── mechanical/ Mechanical sounds via ghurni
├── sampler/ Sample playback via nidhi
├── g2p/ Text-to-phoneme via shabda
└── ffi/ C-compatible API
Full details: docs/architecture/overview.md
Consumers
| Project | Usage |
|---|---|
| shruti | DAW — all audio math (mix, DSP, analysis, transport, synthesis) |
| jalwa | Media player — playback EQ, spectrum visualizer, resampling, normalization |
| aethersafta | Compositor — PipeWire capture, audio mixing for streams |
| kiran | Game engine — game audio, spatial sound, creature/environment synthesis |
Dependency stack
dhvani (audio engine)
├── abaco (DSP math: amplitude/dB, poly_blep, panning, filters)
├── naad (synthesis engines) [feature: synthesis]
├── svara (voice synthesis) [feature: voice]
├── goonj (room acoustics) [feature: acoustics]
├── prani (creature vocals) [feature: creature]
├── garjan (environmental sounds) [feature: environment]
├── ghurni (mechanical sounds) [feature: mechanical]
├── nidhi (sample playback) [feature: sampler]
├── shabda (grapheme-to-phoneme) [feature: g2p]
└── bhava (personality/mood) [feature: bhava-voice]
Building from source
License
GPL-3.0-only. See LICENSE for details.