Here is an example run to show positions of Camera and AudioNode:
Here is copy of console output:
Camera position: (0.0, -0.01, 600.0)
Effect position: (81.000015, -135.00002, 2.75)
Effect position: (81.000015, -135.00002, 2.75)
Camera position: (0.0, -100.01, 700.0)
Camera position: (0.0, -200.01, 800.0)
Camera position: (0.0, -300.00998, 900.0)
Camera position: (0.0, -400.01, 900.0)
Camera position: (0.0, -500.01, 900.0)
Camera position: (0.0, -600.01, 900.0)
Camera position: (0.0, -700.01, 900.0)
Camera position: (0.0, -800.01, 900.0)
Camera position: (0.0, -900.01, 900.0)
Camera position: (0.0, -1000.01, 900.0)
Camera position: (0.0, -1100.01, 900.0)
Camera position: (0.0, -1200.01, 900.0)
Effect position: (81.000015, -135.00002, 2.75)
Effect position: (81.000015, -135.00002, 2.75)
Camera position: (0.0, -1300.01, 900.0)
Camera position: (0.0, -1400.01, 900.0)
Camera position: (0.0, -1500.01, 900.0)
Camera position: (0.0, -1600.0099, 900.0)
Camera position: (0.0, -1700.0099, 900.0)
Camera position: (0.0, -1800.0099, 900.0)
Camera position: (0.0, -1900.0099, 900.0)
Camera position: (0.0, -2000.0099, 900.0)
Camera position: (0.0, -2100.01, 900.0)
Camera position: (0.0, -2200.01, 900.0)
Camera position: (0.0, -2300.01, 900.0)
Camera position: (0.0, -2400.01, 900.0)
Camera position: (0.0, -2500.01, 900.0)
Camera position: (0.0, -2600.01, 900.0)
Camera position: (0.0, -2700.01, 900.0)
Effect position: (81.000015, -135.00002, 2.75)
Effect position: (81.000015, -135.00002, 2.75)
I’m hearing the AudioNode always at the same volume despite using a mono audio file and these settings:
Here is how I create the AudioNodes, it’s attached to a node which represent a tile on the board:
private HashMap<String, AudioNode> soundEffects;
....
// Add sound effects
soundEffects = new HashMap<String, AudioNode>();
soundEffects.put("pickup", createSoundEffect(vm, "cardPlace1.wav"));
soundEffects.put("putdown", createSoundEffect(vm, "cardPlace2.wav"));
soundEffects.put("flip", createSoundEffect(vm, "cardPlace2.wav"));
soundEffects.put("turn", createSoundEffect(vm, "cardPlace2.wav"));
soundEffects.put("shuffle", createSoundEffect(vm, "cardPlace2.wav"));
soundEffects.put("add", createSoundEffect(vm, "cardPlace2.wav"));
soundEffects.put("delete", createSoundEffect(vm, "cardPlace2.wav"));
...
private AudioNode createSoundEffect(ViewModel vm, String filepath) {
AudioNode sound = new AudioNode(vm.app.getAssetManager(), "Sound/Effects/" + filepath, DataType.Buffer);
sound.setPositional(true);
sound.setLooping(false);
sound.setVolume(10);
sound.setRefDistance(2f);
this.attachChild(sound);
return sound;
}
Here is how I play the AudioNode:
public void playSoundEffect(String effectName) {
soundEffects.get(effectName).play();
System.out.println("Effect position: " + soundEffects.get(effectName).getWorldTransform().getTranslation());
}
Here is how I update the Listener position & rotation:
// Set the locations to what was calculated
vm.app.getCamera().setLocation(cameraFake.getWorldTranslation());
vm.app.getCamera().lookAt(lookAtFake.getWorldTranslation(), Vector3f.UNIT_Z);
vm.app.getListener().setLocation(vm.app.getCamera().getLocation());
vm.app.getListener().setRotation(vm.app.getCamera().getRotation());
System.out.println("Camera position: " + vm.app.getListener().getLocation());
I’ve looked at many threads regarding positional audio, this seemed like the closest fit Question concerning positional audionode. Thanks everyone.