Hi,
I was working on my project and started adding some audio to it. I seem not to be able to get the 3d sound to work. I even created a new project to test it. I can hear the sound perfectly but the position has no effect.
Here’s the code of the new empty project:
[java]package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.audio.AudioNode;
public class Main extends SimpleApplication {
private AudioNode audioTest;
private float x;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
Geometry geom = new Geometry(“Box”, b);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor(“Color”, ColorRGBA.Blue);
geom.setMaterial(mat);
rootNode.attachChild(geom);
audioTest = new AudioNode(assetManager, “Sounds/test.wav”, false);
audioTest.setLooping(true);
audioTest.setPositional(true);
audioTest.setRefDistance(10f);
rootNode.attachChild(audioTest);
audioTest.play();
x = 0f;
}
@Override
public void simpleUpdate(float tpf) {
listener.setLocation(cam.getLocation());
listener.setRotation(cam.getRotation());
x += 5*tpf;
audioTest.setLocalTranslation(x, 0f, 0f);
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
[/java]
Is this not working properly or have I missed something important? I tried searching through the JavaDoc and sound examples but didn’t find a solution to this.
Thanks in advance!
It only works with mono sources.