# HG changeset patch # User Robert McIntyre # Date 1320053735 25200 # Node ID 094a92b556a258c4bb015f9806f47bbb7abd0a89 # Parent 2a525e937d864406115c8bb319c2baa49af22c1d still trying to debug stupid program diff -r 2a525e937d86 -r 094a92b556a2 divergence/results.txt --- a/divergence/results.txt Mon Oct 31 01:21:30 2011 -0700 +++ b/divergence/results.txt Mon Oct 31 02:35:35 2011 -0700 @@ -31,3 +31,11 @@ Divergence gets worse the longer things run. + + + +As the sound source moves about the listener in a circle, the sound +should be at a constant volume, since the distance between the source +and listener is constant. Instead, the sound varies depending on where +the thing is in the circle. Main cuts out at around 90degrees, while +aux cuts out at around 180 degrees. diff -r 2a525e937d86 -r 094a92b556a2 src/com/aurellem/capture/examples/AdvancedAudio.java --- a/src/com/aurellem/capture/examples/AdvancedAudio.java Mon Oct 31 01:21:30 2011 -0700 +++ b/src/com/aurellem/capture/examples/AdvancedAudio.java Mon Oct 31 02:35:35 2011 -0700 @@ -21,6 +21,7 @@ import com.jme3.audio.AudioNode; import com.jme3.audio.AudioParam; import com.jme3.audio.Listener; +import com.jme3.audio.ListenerParam; import com.jme3.cinematic.MotionPath; import com.jme3.cinematic.events.MotionTrack; import com.jme3.input.controls.ActionListener; @@ -69,8 +70,8 @@ app.setShowSettings(false); app.setPauseOnLostFocus(false); org.lwjgl.input.Mouse.setGrabbed(false); - try {Capture.captureVideo(app, new File("/home/r/tmp/out.avi"));} - catch (IOException e) {e.printStackTrace();} + //try {Capture.captureVideo(app, new File("/home/r/tmp/out.avi"));} + //catch (IOException e) {e.printStackTrace();} app.start(); } @@ -158,7 +159,7 @@ light.setColor(ColorRGBA.White.mult(1.5f)); rootNode.addLight(light); - ear1 = makeEar(rootNode, new Vector3f(0, 0 ,20)); + ear1 = makeEar(rootNode, new Vector3f(0, 0 ,-20)); //ear2 = makeEar(rootNode, new Vector3f(0, 0 ,-20)); //ear3 = makeEar(rootNode, new Vector3f(20, 0 ,0)); //ear4 = makeEar(rootNode, new Vector3f(-20, 0 ,0)); @@ -204,24 +205,26 @@ private void initAudio() { - music = new AudioNode(assetManager, "Sound/Environment/pure.wav", false); + music = new AudioNode(assetManager, "Sound/Environment/sqr-1kHz.wav", false); rootNode.attachChild(music); - audioRenderer.playSource(music); - music.setPositional(false); - music.setVolume(1f); - music.setReverbEnabled(false); - music.setMaxDistance(200.0f); - music.setRefDistance(1f); - music.setRolloffFactor(5f); - audioRenderer.pauseSource(music); + //audioRenderer.playSource(music); + //music.setPositional(true); + //music.setVolume(1f); + //music.setReverbEnabled(false); + //music.setDirectional(false); + //music.setMaxDistance(200.0f); + //music.setRefDistance(1f); + //music.setRolloffFactor(1f); + //music.setLooping(false); + //audioRenderer.pauseSource(music); } - private Listener auxListener = new Listener(); + private Listener auxListener; //public File data1 = new File("/home/r/tmp/data1.wav"); //public File data2 = new File("/home/r/tmp/data2.wav"); //public File data3 = new File("/home/r/tmp/data3.wav"); @@ -284,6 +287,7 @@ initKeys(); createScene(); listener.setLocation(ear1.getLocalTranslation()); + listener.setRotation(new Quaternion().fromAngleAxis(0, Vector3f.UNIT_Y)); if (this.audioRenderer instanceof MultiListener){ MultiListener rf = (MultiListener)this.audioRenderer; @@ -343,30 +347,40 @@ private int countdown = 0; public void simpleUpdate(float tpf) { + if (countdown == 0){ + music.play(); + } //Vector3f loc = cam.getLocation(); //Quaternion rot = cam.getRotation(); //listener.setLocation(loc); - //listener.setRotation(rot); + listener.setRotation(new Quaternion().fromAngleAxis(0, music.getLocalTranslation().subtract(listener.getLocation()))); + audioRenderer.updateListenerParam(listener, ListenerParam.Rotation); + System.out.println(countdown); - if (countdown++ == 400) { this.requestClose(false);} - System.out.println("channel "+ music.getChannel()); + if (countdown++ == 700) { this.requestClose(false);} + + //System.out.println("channel "+ music.getChannel()); //listener.setLocation(cam.getLocation()); //listener.setRotation(cam.getRotation()); //auxListener.setLocation(loc); //auxListener.setRotation(rot); - if (music.getStatus() != AudioNode.Status.Playing){ + //if (music.getStatus() != AudioNode.Status.Playing){ //audioRenderer.playSource(music); - music.play(); - bell.getMaterial().setColor("Color", ColorRGBA.randomColor()); - System.out.println("I'm playing! <3"); - } + //music.play(); + // bell.getMaterial().setColor("Color", ColorRGBA.randomColor()); + //System.out.println("I'm playing! <3"); + //} //audioRenderer.updateSourceParam(music, AudioParam.Direction); //Vector3f bellVelocity = bell.getLocalTranslation().subtract(prevBellPos).mult(1.0f/tpf); //prevBellPos = bell.getLocalTranslation(); music.setLocalTranslation(bell.getLocalTranslation()); + + System.out.println("distance: " + + music.getLocalTranslation().subtract(listener.getLocation()).length()); + //music.setVelocity(bellVelocity); //audioRenderer.updateSourceParam(music, AudioParam.Position);