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

Stop/pause does not seem to take effect immediately #112

Open
focustense opened this issue Nov 15, 2023 · 1 comment
Open

Stop/pause does not seem to take effect immediately #112

focustense opened this issue Nov 15, 2023 · 1 comment

Comments

@focustense
Copy link

focustense commented Nov 15, 2023

Despite what the docs say: if I call stop or resume on the AudioInstance at approximately the same time as another play request, the stopped audio continues playing for quite some time (I'd estimate maybe 250 ms) before actually stopping.

The default tween is only supposed to be 10 ms, but I've tried zeroing it explicitly with AudioTween:linear(Duration::ZERO) and it doesn't make any difference.

I also put in logs, just to be absolutely sure that I'm really starting/stopping when I think I am, and they say:

2023-11-15T00:39:52.768890Z  INFO myapp::audio: Stop sound: bomb_fuse
2023-11-15T00:39:52.782581Z  INFO myapp::audio: Play sound: bomb_explosion

I added these lines directly above the stop and play calls. So they're ordered correctly, and there's even a delay of a few frames between the stop and start. I shouldn't be able to hear the stopped sound after the new sound has started playing.

Am I doing something wrong? I'm just calling AudioInstance::stop and AudioChannel::play. Both sounds are on the same channel (sfx channel). And I know that the stop is working because the stop-sound is looped, and it does fade out. If I comment out the stop, it keeps playing. So it just takes 250 ms instead of 0 ms to stop.

Bug? Or missed step?


Edit: My estimate of 250 ms was definitely too liberal. It's more like 50 ms. While I can't log when the sound "actually" stops, I can hear them in sync when I force the stop to happen 40 ms earlier (plus the 10-15 ms delay before the next start).

@focustense
Copy link
Author

P.S. I also tried other hacks like set_volume(0.0, AudioTween::linear(Duration::ZERO)) and that didn't help either. I wonder if it's just some sort of latency issue when interacting with the AudioInstance?

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

No branches or pull requests

1 participant