Changing pitch of positional sounds

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?

1 Like

Maybe it’s the pitch competing with the Doppler effect that the sound API tries to do for positional audio?

I’m not sure if there is a way to turn that off or not.

1 Like

I found an old OpenAL guide online:
https://www.openal.org/documentation/OpenAL_Programmers_Guide.pdf

I found the section titled “Doppler Shift” on pages 14-15 to be interesting and relevant.

OpenAL offers a couple ways to tune doppler effects. Unfortunately, jMonkeyEngine’s ALAudioRenderer doesn’t seem to expose any of them.

Seems like a feature worth adding: not all games take place in environments where sound propagates at 340 world units per second.

Btw, for a space game, strict realism would imply no external sounds at all.

PS: A partial workaround would be to scale down the world so that passing ships move at less than 1 world unit per second.

Without sound most space games would end up really dull… even Star Citizen, which aims at high fidelity simulation, has sound in space, because silent games suck :wink:

I will probably end up using a different workaround: other ships have positional sound, but don’t change their pitch, and the players ship (that doesn’t move away from the camera a whole lot) is not positional, but changes pitch. Guess I’ll have to live with that.