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

Implement audio syncing for "stream" sounds #3958

Closed
Herschel opened this issue Apr 10, 2021 · 2 comments
Closed

Implement audio syncing for "stream" sounds #3958

Herschel opened this issue Apr 10, 2021 · 2 comments
Labels
audio Issues relating to audio playback unimplemented Issues for functionality that hasn't been implemented yet

Comments

@Herschel
Copy link
Member

Herschel commented Apr 10, 2021

Playing a "Stream" sound on the timeline triggers frame-skipping behavior in the Flash Player to keep the animation in sync with the sound. Ruffle does not fully implement this.

Currently, Ruffle does frame-skipping at all times, which more-or-less keeps audio in sync for most cases. However, if the audio still manages to get out of sync (because the player or the audio stalls for some amount of time), there is no mechanism to re-sync the animation. This also occurs immediately in some exotic situations, such as when a stream sound is played in a loaded movie that has a different framerate from the root movie.

This should hopefully handle all of these cases:

I'm thinking something like this:

  • On the audio backend, stream sounds keep track of the frame they are on in the movieclip's timeline.
  • Each frame while a stream sound is playing, the player can compare the movieclip's frame to the audio's frame. If these are different, adjust the player's frame timer to skip frames/stall the movie appropriately.
  • Some investigation is necessary to figure out the Flash Player's behavior:
    • How does Flash behave when multiple stream sounds are playing? Does it choose one sound to sync with? (Particularly test when the sounds are from movies with different framerates.)
    • If there is a large discrepancy, say, the audio is suddenly a second+ ahead of the animation, how should we behave? Stop and restart the stream?
@Herschel Herschel added audio Issues relating to audio playback unimplemented Issues for functionality that hasn't been implemented yet labels Apr 10, 2021
@ondaeduca
Copy link

Hi Mike.
I have several activities on the platform that have this problem of synchronization between audio and animation. They all have the audio on the timeline in "stream". I wanted to ask you if it is currently in development and open. I have read that you have rewritten the audio section and you have already worked on these problems, but is it finished or is there still implementation work?

I am attaching an example file, it is somewhat long, but it also happens in other very short 2-3 seconds.
prag_003.zip

thanks!
Javier YH

Herschel added a commit to Herschel/ruffle that referenced this issue Jan 4, 2022
This is a first pass at syncing animation and audio playback when
and embedded audio stream is playing.

Fixes ruffle-rs#3020, ruffle-rs#3663, ruffle-rs#3958.
Herschel added a commit that referenced this issue Jan 7, 2022
This is a first pass at syncing animation and audio playback when
and embedded audio stream is playing.

Fixes #3020, #3663, #3958.
@Herschel
Copy link
Member Author

Herschel commented Jan 7, 2022

Implemented in #5486.

@Herschel Herschel closed this as completed Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio Issues relating to audio playback unimplemented Issues for functionality that hasn't been implemented yet
Projects
None yet
Development

No branches or pull requests

2 participants