Audiostreamplayer.stop() causes popping noise in web build

Godot Version

4.4

Question

I’m having a big issue with the web build of my project. Whenever I stop a sound effect (which is just a long and loud frequency being played), it causes an audible pop noise. This is because the sound goes from being loud to instantly stopping.

I have a very short fade in and fade out effect in my audio clip. Playing it from start to finish has no issues, but if I play it then stop in the middle, it pops.

I tried fading it out using a tween, but that also caused some crackling and popping.

var morse_audio_tween = get_tree().create_tween()
await morse_audio_tween.tween_property($AudioStreamPlayer, "volume_db", -80, 0.1).finished
morse_audio.stop()

I also tried to tween the audio bus volume, muting the audio bus, seeking to the end of the audio clip so it fades out and ends - but all those cause popping as well. At this point I’m getting desperate.

Is there any way to fade out a sound without causing any audio issues?

What happens if you pause the AudioStream instead of stop() it?

morse_audio.stream_paused = true

it seems like this is a known issue

here’s another old forum post that also reports it, though not in the exact same scenario as u

it leads to this ongoing github issue, which has a duplicate with more details

this bug seemed to be fixed in this pull request. tho as the forum post stated, it seems like a partial fix rather than a complete fix. u could try poking around the links i gave - some of them have workarounds.

here’s a reddit thread that contains more relevant information/workarounds/solutions
here’s another one

u may also want to try running the build on another device and see if the problem persists.

2 Likes