v158 · web audio · offline rendering

WAV export pipeline

This is the clipchamp problem at demo scale: render a composition offline and write it to a file, keeping memory flat while you do. The page synthesises a four-bar arpeggio, pulls the output chunk by chunk when this build can, converts each chunk straight to 16-bit PCM, and appends it to a growing WAV — then lets you play and download the actual file it produced.

Chrome targets incremental rendering for Chrome 158 behind the OfflineAudioContextIncrementalRendering runtime flag (--enable-blink-features=OfflineAudioContextIncrementalRendering, or chrome://flags/#enable-experimental-web-platform-features). On an older build the pipeline still produces a correct WAV — via the classic one-shot render — and the banner in the pipeline says which path actually ran. Playback uses a regular AudioContext and needs your click, as all audible audio does.

Run the export

Pipeline not run yet.

0 of 0 frames rendered.

Rendered waveform

Nothing rendered yet.

why chunk-to-encoder matters

A WAV file is a 44-byte header plus raw PCM — which means it can be written incrementally, exactly in step with chunked rendering: each AudioBuffer chunk is interleaved, quantised to int16, and appended; nothing but the current chunk is ever held as float data. The same shape works for feeding an AudioEncoder (WebCodecs) when muxing audio against video — the chunks arrive in time to interleave, instead of one giant buffer arriving after the video is already written.

const wav = [wavHeaderPlaceholder()];
while (ctx.state !== "closed") {
  const chunk = await ctx.startRendering(4096); // ≤ 32 KB of float data in flight
  wav.push(int16Interleave(chunk));             // encode and release
}
patchHeaderWithFinalSize(wav);
const file = new Blob(wav, { type: "audio/wav" });

see also