I used an audio node to play a sound in my game. The sound plays perfectly fine in a menu, but not while the game is running.
Here is what it should sound like/sounds like in menu:
Here is what it sounds like while playing:
The code I am using to play the audio file:
AudioNode node = new AudioNode(Main.instance.getAssetManager(), "Sounds/coin_pickup.wav", AudioData.DataType.Buffer);
node.setVolume(0.6f);
node.play();
I tried with your code, sounds as expected. Surely it’s something you do between menu and game though I can’t imagine what, I tried to mess with it and couldn’t get that
Are you possibly sending the wrong values to the AudioListener object, or maybe using a reference to an incorrect camera once the menus close and the game starts?
// first-person: keep the audio listener moving with the camera
listener.setLocation(cam.getLocation());
listener.setRotation(cam.getRotation());
I had a similar problem as you in the past, but it happened because I tried to set the AudioListener to use the location and rotation of the player’s character model rather than the camera, and it sounded entirely distorted.