feat(webaudio): startAt play property and native infinite loops (1.1.0) - #1
Open
daedeloth wants to merge 2 commits into
Open
feat(webaudio): startAt play property and native infinite loops (1.1.0)#1daedeloth wants to merge 2 commits into
daedeloth wants to merge 2 commits into
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PlayPropsConfig.startAt/instance.startAt: start a Web Audio play at a future AudioContext time, sample-accurately;instance.scheduledAtrecords 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.loop = -1) play on ONE source node withloop = 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;positionwraps to the repetition in progress, pause/resume restart it there,loop = 0lets the repetition finish. It dispatches noloopevent.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 the1.1.0tag and drops the patch. The behavioural tests live in the game'stests/audio-clock.test.js, run against this bundle.🤖 Generated with Claude Code
https://claude.ai/code/session_01HFjCmdKMv9Lj7pJbD7XMp5