Glitched audio on AudioStreamPlayers

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LaranjoLouco

So, i’m adding sounds to my game and i’m experiencing a strage bug with the AudioStreamPlayers. Every time I play a sound that doesnt have a blank second on the beggining, it’s beggining flickers. here’s a video showing the problem

as you can see, when i try to use the immediate audio, it flickers on the beggining, but when i use the audio with 0.8-1 blank second on the beggining, it doesnt flicker. ( and the sounds don’t flicker on the editor too )
I already tried using AudioStreamPlayers and AudioStreamPlayer2Ds ( note that the sfx comes only from the left side cos i forgot to set its position )
And I tried to use .ogg and .wav files too

:bust_in_silhouette: Reply From: Arecher

I suspect that has to do with this filed bug report: https://github.com/godotengine/godot/issues/22016

Some other things to check: Make sure the ‘Trim’ and ‘Normalize’ import settings haven’t messed with anything. And make sure the files are 44100Hz. I have previously had a lot of issues with playback being messed up in the editor whenever the Mix Rate was higher than 44100.

i alrready tried enabling/disabling trim, normalize, and all of the other options and the files are in 44100Hz, and so is the max rate ( I tried different rates too )

LaranjoLouco | 2020-10-30 15:23

In that case perhaps all you can do is wait for the bug to be resolved. As far as I know the issue was resolved and merged into the branch, so the next Godot Update should likely fix your issue.

But do read the GitHub Issue, and report a new issue if you think your bug is different.

Arecher | 2020-10-30 15:29

So, now i know the problem. I was calling the play function when a key were pressed ( i’m using Input.is_action_just_pressed ). is_action_just_pressed triggers for some frames instead of just 1 IF you’re loading it on _process, so i just need to change the Input handling to _input() instead of _process()

LaranjoLouco | 2020-10-30 17:09

:bust_in_silhouette: Reply From: LaranjoLouco

So, now i know the problem. I was calling the play function when a key were pressed ( i’m using Input.is_action_just_pressed ). is_action_just_pressed triggers for some frames instead of just 1 IF you’re loading it on _process, so i just need to change the Input handling to _input() instead of _process()