Quack solid bundling
Bundle game audio automatically in @quajs/quack with latency-aware .qaa streaming separation, sharded .qaab banks, and transparent QAAR stubs.
@quajs/quaaudio/quack connects QuaAudio directly to Quack (@quajs/quack), QuaEngine's asset packager, so games gain cross-track solid compression without rewriting any .qs script paths.
Enabling in quack.config.ts
TypeScriptimport { defineConfig } from '@quajs/quack'export default defineConfig({ source: './assets', output: './dist/game.qpk', format: 'qpk', // Default: spectral lossless + cross-track .qaab solid banks with QAAR pointers solidAudio: true, // Or configure perceptual spatial VBR with a target compression ratio: // solidAudio: { mode: 'lossy', targetRatio: 12 },})
Latency-aware packing strategy
packAudioAssetsIntoSolidBank(assets, options) splits audio assets by duration so streaming music and short voice/SFX clips each get optimal layout:
- Long tracks (
duration >= streamThresholdSeconds, default15seconds, e.g., BGM):- Encoded as standalone seekable
.qaapayloads (mimeType = 'audio/x-quaaudio') at their original logical path. - Enables
O(1)-memory cluster streaming viaQaaStreamDecoderwithout decompressing an entire multi-track solid chunk.
- Encoded as standalone seekable
- Short & medium clips (
< 15seconds, e.g., dialogue & SFX):- Sorted by
(localePrefix, dirname, relativePath)to keep related directory assets together, then acoustically ordered inside.qaab. - Partitioned by
maxBankRawBytes(default8 MiBraw PCM per shard, typically~500 KiB – 1.2 MiBon disk) intodata/__quaaudio__/solid.qaab,data/__quaaudio__/solid.0001.qaab, and so on. - Original asset entries retain their logical path (e.g.,
audio/voice/ch01/001.ogg), storing a compactQAARpointer stub (mimeType = 'audio/x-quaaudio-ref') carryingbankPathandtrackKey(${localePrefix}:${relativePath}).
- Sorted by
Tip: Set
streamThresholdSecondsto0orInfinityto force all audio into.qaabshards, or setsolidBank: falseto emit standalone.qaatracks for every asset.
Per-asset QuaAudioPlugin
For custom Quack plugin pipelines that transcode tracks individually to .qaa:
TypeScriptimport { QuaAudioPlugin } from '@quajs/quaaudio/quack'const plugin = new QuaAudioPlugin({ mode: 'lossy', targetRatio: 12, rewriteExtension: false, // Default: keeps @PlayBGM('audio/bgm/night.ogg') paths intact})
Source format decoding & ffmpeg
WAV and existing .qaa buffers decode directly inside QuaAudio with zero subprocess calls. Other extensions (.ogg, .opus, .mp3, .flac, .aac, .m4a) are decoded to 24-bit lossless pcm_s24le WAV via ffmpeg:
- Streams over
pipe:0/pipe:1first to avoid temporary disk writes; - Falls back cleanly to a temporary file for seek-dependent containers such as
.m4a; - Supports custom
ffmpegBinarypaths andallowPassthroughOnDecodeError: truewhen mock/placeholder audio buffers appear in tests.