Skip to content

feat(webaudio): startAt play property and native infinite loops (1.1.0) - #1

Open
daedeloth wants to merge 2 commits into
masterfrom
feature/native-loops-start-at
Open

feat(webaudio): startAt play property and native infinite loops (1.1.0)#1
daedeloth wants to merge 2 commits into
masterfrom
feature/native-loops-start-at

Conversation

@daedeloth

Copy link
Copy Markdown
Member

Summary

  • PlayPropsConfig.startAt / instance.startAt: start a Web Audio play at a future AudioContext time, sample-accurately; instance.scheduledAt records when the play started or will start. A "now" start lands on the next render quantum (up to 171 ms of jitter on a Google TV Streamer), which a booking made ahead of time avoids.
  • Infinite loops (loop = -1) play on ONE source node with loop = true (WebAudioSoundInstance.nativeLoops, default true). SoundJS's node chain was refilled by a timer armed relative to when it last ran, so main-thread stalls accumulated and once they added up to a loop length the next repetition was created late: an audible gap (4-6 s measured on a TV). A native loop involves no JS while it plays; position wraps to the repetition in progress, pause/resume restart it there, loop = 0 lets the repetition finish. It dispatches no loop event.
  • lib/ rebuilt as 1.1.0 (tagged); line endings normalised to LF.

Both features were first shipped as a runtime prototype patch in client.quizwitz.com (Quizted/Utils/AudioClock.js, PR CatLabInteractive/client.quizwitz.com#164) and verified on the device there; that PR now pins bower to the 1.1.0 tag and drops the patch. The behavioural tests live in the game's tests/audio-clock.test.js, run against this bundle.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HFjCmdKMv9Lj7pJbD7XMp5

daedeloth and others added 2 commits September 11, 2026 13:46
- PlayPropsConfig.startAt / instance.startAt: start a Web Audio play at
  a future AudioContext time, sample-accurately; instance.scheduledAt
  records when the play started or will start. A "now" start lands on
  the next render quantum (up to 171 ms of jitter on a Google TV
  Streamer), which a booking made ahead of time avoids.
- Infinite loops (loop = -1) play on ONE source node with loop = true
  (WebAudioSoundInstance.nativeLoops, default true). The node chain
  was refilled by a timer armed relative to when it last ran, so
  main-thread stalls accumulated and once they added up to a loop
  length the next repetition was created late: an audible gap (4-6 s
  measured on a TV). A native loop involves no JS while it plays;
  position wraps to the repetition in progress, pause/resume restart
  it there, loop = 0 lets the repetition finish. No "loop" event.
- lib/ rebuilt (grunt setVersion updateversion combine uglify
  clearversion copy:src) as 1.1.0; line endings normalised to LF.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HFjCmdKMv9Lj7pJbD7XMp5
Sound.play / instance.play apply play props one by one in
AbstractSoundInstance._beginPlaying and never call applyPlayProps, so
a startAt passed as a play property was ignored and the play started
immediately. Verified on a Google TV Streamer: a segment booked for a
beat 640 ms ahead started at once, overlapping the outgoing loop that
was muted on the beat.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HFjCmdKMv9Lj7pJbD7XMp5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant