Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Music: fix triggered sounds sometimes not playing #48875

Merged
merged 1 commit into from
Oct 27, 2022

Conversation

breville
Copy link
Member

Screenshot 2022-10-26 at 10 21 37 PM

Sometimes, a triggered sound played at currentTime wouldn't be played. This was because the current audio time had progressed slightly beyond the event time by the time we got to the code that sets up the play.

The fix:

Triggered sounds might have a target play time that is very slightly in the past, specificially when they use the currentTime passed (slightly earlier) into the event handler code as the target play time.

To compensate for this delay, if the target play time is within a tenth of a second of the current play time, then play it.

Note that we still don't play sounds older than that, because they might have been scheduled for some time ago, and Web Audio will play a sound immediately if its target time is in the past.

Sometimes, a triggered sound played at currentTime wouldn't be played.
Copy link
Contributor

@molly-moen molly-moen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for including a descriptive comment!

Copy link
Contributor

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@breville breville merged commit a6fb522 into staging Oct 27, 2022
@breville breville deleted the music-trigger-delay-compensation branch October 27, 2022 19:39
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.

None yet

3 participants