← Gallery AudioPlayer — event-contract playback

AudioPlayer — event-contract playback

scripts/analysis/AudioPlayer.ts

Set a loop on a real drum recording and the player has to keep its promises: playback stays inside the loop region, and pausing then resuming picks up right where you left off. Every badge asserts the EVENT payloads the player emits, not internal state, on the 15 s golden WAV: (1) setLoop(10, 9999) fires loopchange with end clamped to buffer.duration exactly; (2) during looped playback 200 consecutive timeupdate values all land inside [loop.start, loop.end] — this exercises the 2026-07-02 clock repair (the wall-clock reference now tracks the actual start offset, so even first-cycle values are in bounds); (3) pause()/play() continuity — the clock resumes within 60 ms of the paused position (resume now also continues the AUDIO from the paused position instead of silently restarting the loop); (4) the state getter mirrors the last events. Clamp + state asserts spot-run headless in Node pre-ship.

press run