AudioStreamPlayer Not Playing Sound In-Game, But Plays In-Editor

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

Hey All,

I have done this >100 times and never had this issue. I have an AudioStreamPlayer with a .wav file in the stream. In the editor, if I press playing/set it to true, I hear the sound just fine. For some reason, however, calling from code makes no sound in-game.

It gets weirder… as a test, I connected the AudioStreamPlayer’s “finishedsignal and told it to print when the _on_finished() function ran… and it did. So it is playing, but there is no sound?

I tested sounds from one of my old games and they played fine, so I think it is the sound file, but it’s very weird to me that it plays in the editor but not in-game.

Any Ideas???

An idea: did you check audio buses, the default layout, maybe a script mutes a bus?

1234ab | 2021-04-02 16:49

Are you playing your sound on a autoload singleton or on a node in the scene tree?

MikeSundaysGameDev | 2021-04-11 08:34

:bust_in_silhouette: Reply From: Mrpaolosarino

Maybe you are playing the music in the physics_process? What happen is it continuously play over and over that you can’t hear.
What you do is you add a boolean:

if AudioStreamPlayer.playing == false:
:bust_in_silhouette: Reply From: noodlelou

I had the same issue, if you are using a viewport, you must go into the viewport settings and under ‘Audio Listener’ enable 3d audio.

This solved my issue, thank you!

chabet | 2022-04-28 07:23

:bust_in_silhouette: Reply From: kennychidot

@ Mrpaolosarino has suggested one reason why this can happen but I will mention another reason this can happen.Do not forget the max_distance property which as the name implies controls the range at which the sound can be heard from a player’s position in the scene.So increase it if you don’t hear any sound or just position the audiostreamplayer close to the player.

:bust_in_silhouette: Reply From: scrubswithnosleeves

The problem was had to do with the way my audio program (Traction Waveform) was exporting the .wav files. If I “edited” and exported the files in audacity, the issue went away.

Also, this was 2D.