A high-performance, studio-grade audio dithering engine that converts high-resolution audio (e.g., 24-bit/32-bit float) to 16-bit while preserving dynamic range and eliminating quantization distortion via psychoacoustic noise shaping.
When high-quality audio is shrunk down to standard 16-bit formats, microscopic sound details are lost, creating a "crunchy" background static known as quantization error.
This engine fixes that by using advanced math to add a tiny, almost invisible layer of "smart" static (dither) back into the audio. The algorithm uses psychoacoustics (how the human brain perceives sound) to push all that static into super-high frequencies that human ears cannot hear, preserving the original studio quality.
Built for maximum hardware acceleration and zero latency:
- Rust SIMD DSP Core: Audio is processed using portable SIMD (
f64x2) in Rust for maximum throughput. - Zero-Copy Go FFI (
purego): Bypasses standard CGO overhead. Go passes raw memory pointers directly to the Rust SIMD pipeline for zero-copy execution. - eBPF Tracing (
usdt): Features embedded User Statically-Defined Tracing (USDT) probes for zero-overhead, nanosecond-precision latency profiling in production. - Hardware-Accelerated AES-GCM: Includes a
tonicgRPC microservice that end-to-end encrypts audio streams using AES-NI/NEON instructions. - Embedded DSP Targets: The Rust DSP core is
#![no_std]compliant and can be natively cross-compiled for bare-metal execution on Cortex-M4 DSPs (thumbv7em-none-eabihf).
- Go 1.21+
- Rust (Nightly) (for
#![feature(portable_simd)])
-
Build the Rust Core:
cd dsp-core cargo build --release -
Use in Go: The
ditherpackage automatically loadslibdsp_corevia zero-copy FFI.import "github.com/ParkWardRR/noise-shaped-dither-vartenia" ns := dither.NewNoiseShaper(dither.DitherLipshitz) output16Bit := ns.DitherStereoF64(raw64BitFloatAudio, 16)
Run unit tests and benchmarks:
go test -v ./...
go test -bench .Run fuzzing:
go test -fuzz=Fuzz -fuzztime=10sRun CI pipelines locally via OrbStack and act:
act -W .local-ci/workflows