QuaAudio handbook
Explore QuaAudio's cleanroom architecture, dual-level solid compression, and integration across TypeScript, Rust, and Quack.
QuaAudio (@quajs/quaaudio / quaaudio) is an original, cleanroom, patent-free audio codec and dual-level solid audio bank system engineered for QuaEngine. Its core DSP and entropy engine is written in pure Rust and compiles deterministically into a native Rust crate, a standalone CLI, and a self-contained WebAssembly binary embedded in the npm package.
Architecture & data flow
TextSource PCM / WAV / FFmpeg input (.ogg / .mp3 / .flac / .m4a) │ ├──▶ Mode 1: Spectral Lossless (default, mode: 'lossless') │ └─ Q24 IntMDCT + 6-stage silence & redundancy elision ──▶ 100% bit-exact PCM │ └──▶ Mode 2: Perceptual Spatial VBR (mode: 'lossy', targetRatio) └─ Full-band MDCT + Bark/Terhardt masking + QAA-Spatial ──▶ ratio-targeted VBR │ ├──▶ Single-track seekable solid file (.qaa / QAA1) │ └─ 64-frame clusters (~1.36s @ 48 kHz) split into meta / quot / micro streams │ └──▶ Cross-track solid audio bank (.qaab / QAAB + QAAR stubs) └─ 32-band Bark TSP ordering + LBG envelope codebook + 1 MiB solid chunks
Choosing a format and mode
| Workload | Recommended artifact | Key properties | When to choose |
|---|---|---|---|
| Voice lines, SFX, short cues | Solid .qaab + QAAR stub |
Acoustic TSP clustering, shared LBG codebook, 1 MiB cross-track dictionary | Default bundling path for clips < 15s in Quack bundles |
| Long background music (BGM) | Standalone .qaa (lossless or VBR) |
O(1)-memory QaaStreamDecoder, O(log C) sample-accurate seeking |
Tracks >= 15s to avoid holding whole-bank memory spikes during streaming |
| Archival & bit-exact playback | .qaa Spectral Lossless (default) |
3-shear IntMDCT + pre-emphasis / LPC-8 competition, maxAbsDiff = 0 |
Bit-exact determinism across x86_64, aarch64, and wasm32 |
| Strict bundle size budgets | .qaa Perceptual Spatial VBR |
Full Nyquist bandwidth, HF air restoration, QAA-Spatial stereo width |
Target exact compression ratios (12:1, 16:1, 24:1, etc.) |
Try it live: The homepage specimen embeds a real wind-chime phrase encoded as Lossless
.qaa, Spatial VBR12×, and a 4-track.qaabsolid bank—decode and inspect them live in browser WebAssembly on the landing page.
Reading guide
Integration guides
- TypeScript & WebAudio — Encode PCM or WAV buffers, inspect headers without WASM, decode directly into WebAudio
AudioBufferinstances, or resolve legacy WAV fallbacks via@quajs/quaaudio. - Rust & cluster streaming — Use the
quaaudiocrate natively, stream long tracks in bounded memory withQaaStreamDecoder, and serve dialogue clips throughSolidBankArchive. - Quack solid bundling — Partition short clips and long BGM automatically with
packAudioAssetsIntoSolidBankandQuaAudioPluginwhile keeping logical asset paths intact. - CLI reference — Run
quaaudio encode,decode,bank,extract, andinfofrom your terminal or asset pipelines.
Internals, benchmarks & reference
- DSP & Cleanroom IP — Reversible 3-shear
IntMDCT, multi-stage redundancy elision,QAA-Spatialbinaural coding, 3-stream Lazy LZ77 + rANS, and mathematical provenance (CLEANROOM.md). - V2 benchmarks — Measured V2 results at 48 kHz stereo against FLAC-8, MP3 (LAME), Ogg Vorbis, and Opus, plus instructions for running
pnpm run bench. - Container specifications — Byte-accurate wire layouts for
QAA1,QAAB, andQAARalong with registered MIME types. - API Reference — Complete symbol documentation for TypeScript and Rust.