Audio levels are held over when playback is stopped

Describe the bug (REQUIRED)
Not exactly sure if this is intended or not, but from an audio standpoint it makes absolutely no sense, so I am posting here. When using the functions to get the peak or RMS levels of a mixer group - when playback has stopped, it returns the value for the last moment of when playback stopped and the time window before that point. If you were to look at a mixing console for the RMS level while there is no audio playing, you would expect everything to read 0, right? That’s not the case here.

This makes trying to get something to react to sound pretty hard, as you need to add a step for overriding the held over values when the music stops - and it also means that checking if something is not playing anymore by just checking the levels is not possible.

To Reproduce (REQUIRED)
You can reproduce this by playing through a mixer group, stopping the sound while it’s playing and then printing the peak or RMS level from callback in a timer with a delay way past when the sound source has already stopped. It returns the exact same values as calling the function as soon as you stop the sound does.

Expected behavior (REQUIRED)
sound.get_rms() and sound.get_peak() should return 0 when there is nothing playing.

Defold version (REQUIRED):
1.2.167

1 Like

Since these are values that are continuously updated, we have the window argument to specify how far back you’ll calculate it.

What value do you have for window?

I think I understand what you mean now.
My guess is that we perhaps do an early-out in the update when the sound gain is zero.
If so, we might not clear the buffers correctly.
A way to test that theory might be to set the group gain to something really small but above 0 and see if that works better.

Would you mind creating a small repro for us to test this out?

2 Likes