← Gallery Loop buffer builder — synth, measure, loop, export

Loop buffer builder — synth, measure, loop, export

scripts/audio-utils.js

This page builds a two-second seamless sine loop from scratch, measures it, marks its loop points on the waveform, and exports it as a WAV you can download — press play and it should repeat with no click at the seam. Under the hood, createLoopBuffer builds a 4×0.5 s 440 Hz sine loop buffer (post-repair: constructs the AudioBuffer directly — no more leaked live AudioContext per call); metric badges are asserted against sine theory (RMS 1/√2, peak 1.0, ZCR 2f/sr); the export badge encodes the buffer through exportBufferAsWav (io/wav tier) and re-decodes it in-page with decodeWav; loop markers come from defineMultipleLoopPoints. Metric math node-verified 2026-07-02 with a duck-typed buffer (rms 0.70711, peak 0.9999998, zcr 0.019944).