Mercurial > jmeCapture
changeset 37:094a92b556a2
still trying to debug stupid program
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 31 Oct 2011 02:35:35 -0700 |
parents | 2a525e937d86 |
children | adeb88787645 |
files | divergence/results.txt src/com/aurellem/capture/examples/AdvancedAudio.java |
diffstat | 2 files changed, 43 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/divergence/results.txt Mon Oct 31 01:21:30 2011 -0700 1.2 +++ b/divergence/results.txt Mon Oct 31 02:35:35 2011 -0700 1.3 @@ -31,3 +31,11 @@ 1.4 1.5 1.6 Divergence gets worse the longer things run. 1.7 + 1.8 + 1.9 + 1.10 +As the sound source moves about the listener in a circle, the sound 1.11 +should be at a constant volume, since the distance between the source 1.12 +and listener is constant. Instead, the sound varies depending on where 1.13 +the thing is in the circle. Main cuts out at around 90degrees, while 1.14 +aux cuts out at around 180 degrees.
2.1 --- a/src/com/aurellem/capture/examples/AdvancedAudio.java Mon Oct 31 01:21:30 2011 -0700 2.2 +++ b/src/com/aurellem/capture/examples/AdvancedAudio.java Mon Oct 31 02:35:35 2011 -0700 2.3 @@ -21,6 +21,7 @@ 2.4 import com.jme3.audio.AudioNode; 2.5 import com.jme3.audio.AudioParam; 2.6 import com.jme3.audio.Listener; 2.7 +import com.jme3.audio.ListenerParam; 2.8 import com.jme3.cinematic.MotionPath; 2.9 import com.jme3.cinematic.events.MotionTrack; 2.10 import com.jme3.input.controls.ActionListener; 2.11 @@ -69,8 +70,8 @@ 2.12 app.setShowSettings(false); 2.13 app.setPauseOnLostFocus(false); 2.14 org.lwjgl.input.Mouse.setGrabbed(false); 2.15 - try {Capture.captureVideo(app, new File("/home/r/tmp/out.avi"));} 2.16 - catch (IOException e) {e.printStackTrace();} 2.17 + //try {Capture.captureVideo(app, new File("/home/r/tmp/out.avi"));} 2.18 + //catch (IOException e) {e.printStackTrace();} 2.19 app.start(); 2.20 } 2.21 2.22 @@ -158,7 +159,7 @@ 2.23 light.setColor(ColorRGBA.White.mult(1.5f)); 2.24 rootNode.addLight(light); 2.25 2.26 - ear1 = makeEar(rootNode, new Vector3f(0, 0 ,20)); 2.27 + ear1 = makeEar(rootNode, new Vector3f(0, 0 ,-20)); 2.28 //ear2 = makeEar(rootNode, new Vector3f(0, 0 ,-20)); 2.29 //ear3 = makeEar(rootNode, new Vector3f(20, 0 ,0)); 2.30 //ear4 = makeEar(rootNode, new Vector3f(-20, 0 ,0)); 2.31 @@ -204,24 +205,26 @@ 2.32 2.33 private void initAudio() { 2.34 2.35 - music = new AudioNode(assetManager, "Sound/Environment/pure.wav", false); 2.36 + music = new AudioNode(assetManager, "Sound/Environment/sqr-1kHz.wav", false); 2.37 2.38 rootNode.attachChild(music); 2.39 - audioRenderer.playSource(music); 2.40 - music.setPositional(false); 2.41 - music.setVolume(1f); 2.42 - music.setReverbEnabled(false); 2.43 - music.setMaxDistance(200.0f); 2.44 - music.setRefDistance(1f); 2.45 - music.setRolloffFactor(5f); 2.46 - audioRenderer.pauseSource(music); 2.47 + //audioRenderer.playSource(music); 2.48 + //music.setPositional(true); 2.49 + //music.setVolume(1f); 2.50 + //music.setReverbEnabled(false); 2.51 + //music.setDirectional(false); 2.52 + //music.setMaxDistance(200.0f); 2.53 + //music.setRefDistance(1f); 2.54 + //music.setRolloffFactor(1f); 2.55 + //music.setLooping(false); 2.56 + //audioRenderer.pauseSource(music); 2.57 2.58 } 2.59 2.60 2.61 2.62 2.63 - private Listener auxListener = new Listener(); 2.64 + private Listener auxListener; 2.65 //public File data1 = new File("/home/r/tmp/data1.wav"); 2.66 //public File data2 = new File("/home/r/tmp/data2.wav"); 2.67 //public File data3 = new File("/home/r/tmp/data3.wav"); 2.68 @@ -284,6 +287,7 @@ 2.69 initKeys(); 2.70 createScene(); 2.71 listener.setLocation(ear1.getLocalTranslation()); 2.72 + listener.setRotation(new Quaternion().fromAngleAxis(0, Vector3f.UNIT_Y)); 2.73 if (this.audioRenderer instanceof MultiListener){ 2.74 MultiListener rf = (MultiListener)this.audioRenderer; 2.75 2.76 @@ -343,30 +347,40 @@ 2.77 private int countdown = 0; 2.78 2.79 public void simpleUpdate(float tpf) { 2.80 + if (countdown == 0){ 2.81 + music.play(); 2.82 + } 2.83 //Vector3f loc = cam.getLocation(); 2.84 //Quaternion rot = cam.getRotation(); 2.85 //listener.setLocation(loc); 2.86 - //listener.setRotation(rot); 2.87 + listener.setRotation(new Quaternion().fromAngleAxis(0, music.getLocalTranslation().subtract(listener.getLocation()))); 2.88 + audioRenderer.updateListenerParam(listener, ListenerParam.Rotation); 2.89 + 2.90 System.out.println(countdown); 2.91 - if (countdown++ == 400) { this.requestClose(false);} 2.92 2.93 - System.out.println("channel "+ music.getChannel()); 2.94 + if (countdown++ == 700) { this.requestClose(false);} 2.95 + 2.96 + //System.out.println("channel "+ music.getChannel()); 2.97 //listener.setLocation(cam.getLocation()); 2.98 //listener.setRotation(cam.getRotation()); 2.99 //auxListener.setLocation(loc); 2.100 //auxListener.setRotation(rot); 2.101 - if (music.getStatus() != AudioNode.Status.Playing){ 2.102 + //if (music.getStatus() != AudioNode.Status.Playing){ 2.103 //audioRenderer.playSource(music); 2.104 - music.play(); 2.105 - bell.getMaterial().setColor("Color", ColorRGBA.randomColor()); 2.106 - System.out.println("I'm playing! <3"); 2.107 - } 2.108 + //music.play(); 2.109 + // bell.getMaterial().setColor("Color", ColorRGBA.randomColor()); 2.110 + //System.out.println("I'm playing! <3"); 2.111 + //} 2.112 //audioRenderer.updateSourceParam(music, AudioParam.Direction); 2.113 2.114 //Vector3f bellVelocity = bell.getLocalTranslation().subtract(prevBellPos).mult(1.0f/tpf); 2.115 //prevBellPos = bell.getLocalTranslation(); 2.116 2.117 music.setLocalTranslation(bell.getLocalTranslation()); 2.118 + 2.119 + System.out.println("distance: " + 2.120 + music.getLocalTranslation().subtract(listener.getLocation()).length()); 2.121 + 2.122 //music.setVelocity(bellVelocity); 2.123 2.124 //audioRenderer.updateSourceParam(music, AudioParam.Position);