Main thread
The tap creates the AudioContext, calls resume(), and wires a worker to an AudioWorkletNode. It never reads the file.
Stream a WAV from the network into an AudioWorklet without handing the bytes to the main thread.
Tap to play
Source on GitHub“Zero-copy” here means the file bytes change owner instead of being cloned through the main thread. postMessage normally structured-clones data. A transfer list moves the object: the sender loses it, the receiver gets it.
The worker fetches Range slices of the WAV. It then does one of two transfers into the worklet’s MessagePort:
ReadableStream in the transfer list. The worklet reads that same stream.DataCloneError on a stream. The worker transfers each chunk’s ArrayBuffer instead. The buffer is detached, not copied.Decoding is not free. The worklet turns integer PCM into floats and writes those into the Float32Arrays Web Audio already allocated for process(). The network hop is the part that does not copy.
The tap creates the AudioContext, calls resume(), and wires a worker to an AudioWorkletNode. It never reads the file.
transfer MessagePort → worker
fetch with Range: bytes=start-endArrayBuffertransfer bytes → audio thread
process() fills ~128 frames per callbackin-place write → speakers