370 MB -> 17 MB without losing quality
First wasm bundle I built was a clean 370 MB. A piano sample is a 10 s stereo 44.1 kHz WAV and we ship one per key. Not quite portfolio material :upsidedown:
How I got to 17 MB:
- Subset preload.
bash + jqscript reads each track's notes, picks only the sampler slots actually used.~70samples ->19 - Trim length. Source samples are 10 s sustained notes, but the sampler has its own release envelope. Tail past 2 s is wasted bytes. Wrote a
30-linehostCtool using the engine's ownwav_read_mono_f32 - Mono on disk. The sampler downmixes anyway. Halve the bytes for free
- FLAC: aborted.
miniaudiodecodes FLAC but only encodesWAV, andffmpegisn't on the build host. Not worth vendoringlibFLACfor6 MB
Loads in a few seconds even on 4G. Good enough :)
