Hi,
in my space game the player can control the speed of his space ship. I want to simulate the engine sound by altering the pitch of the sound - the faster the space ship, the higher the pitch.
Since this is a multiplayer game the engines of other ships should work like this too, and they also have to be positional.
This combination (positional sounds + changing pitches) causes really bad sound artifacts. When I don’t change pitches or I don’t mark my AudioNodes as positional, they don’t occur. Is this a known issue?
I tried disabling reverb, but this did nothing.
Here is the code I use for the AudioNode:
AudioNode audioNode = new AudioNode(assetManager, "assets/sounds/engine1.wav", DataType.Buffer);
audioNode.setLooping(true);
audioNode.setPositional(true);
ship.attachChild(audioNode);
audioNode.play();
ship.addControl(new EngineAudioControl(audioNode));
And here I change the pitch in my EngineAudioControl:
float forwardSpeedPercentage = moveInfo.getForwardSpeedPercentage();
float pitch = 1f + (forwardSpeedPercentage / 4f); // forwardSpeedPercentage has maximum of 1.0
if (currentPitch != pitch) { // I save the current pitch so I don't call setPitch on every frame unnecessarily
audioNode.setPitch(pitch);
currentPitch = pitch;
}
And of course I added the 2 lines for the listener in my SimpleApplication.simpleUpdate method.
I even tried this with a really simple sin-wave (created with Audacity), both with the .ogg and .wav format.
I’m testing this under ubuntu 18.04 on a desktop PC, I don’t have any other sound issues and my ubuntu (and therefore my sound driver) is up-to-date.
Any ideas? Do you need any more information?