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).
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?
Despite what the docs say: if I call
stop
orresume
on theAudioInstance
at approximately the same time as anotherplay
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:
I added these lines directly above the
stop
andplay
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
andAudioChannel::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).