Documentation
¶
Overview ¶
Command wasm registers the AlgoTom API on the worker's global scope.
It serves two workers from one binary. The audio worker holds the live DoubleHead and calls only the short methods — trigger, render, setParam. The analysis worker runs extract, explain, decayTrace, spectrum and the sweep loop, every one of which is FFT-heavy and would stall the audio if it shared a runtime with it. Go's js/wasm is single-threaded, so the concurrency comes from two runtime instances of the same module rather than from goroutines, and each simply ignores the half of the API it does not use.
Everything crossing the boundary is either a number, a Float32Array, or a JSON string. Audio is Float32Array because that is what Web Audio and the WAV decoder both already hold, and the conversion is exact in both directions for anything that came out of a PCM file. Structures are JSON because the alternative is a hand-written mirror of thirty Go types on the TypeScript side, which is the drift this repository generates tomParams to avoid.