Skip to content

Repository files navigation

noise-shaped-dither-vartenia

Language License Status

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.

What is this?

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.

Architecture

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 tonic gRPC 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).

Requirements

  • Go 1.21+
  • Rust (Nightly) (for #![feature(portable_simd)])

Quick Start

  1. Build the Rust Core:

    cd dsp-core
    cargo build --release
  2. Use in Go: The dither package automatically loads libdsp_core via zero-copy FFI.

    import "github.com/ParkWardRR/noise-shaped-dither-vartenia"
    
    ns := dither.NewNoiseShaper(dither.DitherLipshitz)
    output16Bit := ns.DitherStereoF64(raw64BitFloatAudio, 16)

Development & Testing

Run unit tests and benchmarks:

go test -v ./...
go test -bench .

Run fuzzing:

go test -fuzz=Fuzz -fuzztime=10s

Run CI pipelines locally via OrbStack and act:

act -W .local-ci/workflows

About

Professional noise-shaped dithering library in Go for audio bit-depth reduction. Implements flat TPDF, F-weighted, E-weighted, and Lipshitz minimal-audibility algorithms.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages