Mercurial > jmeCapture
diff src/com/aurellem/capture/examples/AdvancedAudio.java @ 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 |
line wrap: on
line diff
1.1 --- a/src/com/aurellem/capture/examples/AdvancedAudio.java Mon Oct 31 01:21:30 2011 -0700 1.2 +++ b/src/com/aurellem/capture/examples/AdvancedAudio.java Mon Oct 31 02:35:35 2011 -0700 1.3 @@ -21,6 +21,7 @@ 1.4 import com.jme3.audio.AudioNode; 1.5 import com.jme3.audio.AudioParam; 1.6 import com.jme3.audio.Listener; 1.7 +import com.jme3.audio.ListenerParam; 1.8 import com.jme3.cinematic.MotionPath; 1.9 import com.jme3.cinematic.events.MotionTrack; 1.10 import com.jme3.input.controls.ActionListener; 1.11 @@ -69,8 +70,8 @@ 1.12 app.setShowSettings(false); 1.13 app.setPauseOnLostFocus(false); 1.14 org.lwjgl.input.Mouse.setGrabbed(false); 1.15 - try {Capture.captureVideo(app, new File("/home/r/tmp/out.avi"));} 1.16 - catch (IOException e) {e.printStackTrace();} 1.17 + //try {Capture.captureVideo(app, new File("/home/r/tmp/out.avi"));} 1.18 + //catch (IOException e) {e.printStackTrace();} 1.19 app.start(); 1.20 } 1.21 1.22 @@ -158,7 +159,7 @@ 1.23 light.setColor(ColorRGBA.White.mult(1.5f)); 1.24 rootNode.addLight(light); 1.25 1.26 - ear1 = makeEar(rootNode, new Vector3f(0, 0 ,20)); 1.27 + ear1 = makeEar(rootNode, new Vector3f(0, 0 ,-20)); 1.28 //ear2 = makeEar(rootNode, new Vector3f(0, 0 ,-20)); 1.29 //ear3 = makeEar(rootNode, new Vector3f(20, 0 ,0)); 1.30 //ear4 = makeEar(rootNode, new Vector3f(-20, 0 ,0)); 1.31 @@ -204,24 +205,26 @@ 1.32 1.33 private void initAudio() { 1.34 1.35 - music = new AudioNode(assetManager, "Sound/Environment/pure.wav", false); 1.36 + music = new AudioNode(assetManager, "Sound/Environment/sqr-1kHz.wav", false); 1.37 1.38 rootNode.attachChild(music); 1.39 - audioRenderer.playSource(music); 1.40 - music.setPositional(false); 1.41 - music.setVolume(1f); 1.42 - music.setReverbEnabled(false); 1.43 - music.setMaxDistance(200.0f); 1.44 - music.setRefDistance(1f); 1.45 - music.setRolloffFactor(5f); 1.46 - audioRenderer.pauseSource(music); 1.47 + //audioRenderer.playSource(music); 1.48 + //music.setPositional(true); 1.49 + //music.setVolume(1f); 1.50 + //music.setReverbEnabled(false); 1.51 + //music.setDirectional(false); 1.52 + //music.setMaxDistance(200.0f); 1.53 + //music.setRefDistance(1f); 1.54 + //music.setRolloffFactor(1f); 1.55 + //music.setLooping(false); 1.56 + //audioRenderer.pauseSource(music); 1.57 1.58 } 1.59 1.60 1.61 1.62 1.63 - private Listener auxListener = new Listener(); 1.64 + private Listener auxListener; 1.65 //public File data1 = new File("/home/r/tmp/data1.wav"); 1.66 //public File data2 = new File("/home/r/tmp/data2.wav"); 1.67 //public File data3 = new File("/home/r/tmp/data3.wav"); 1.68 @@ -284,6 +287,7 @@ 1.69 initKeys(); 1.70 createScene(); 1.71 listener.setLocation(ear1.getLocalTranslation()); 1.72 + listener.setRotation(new Quaternion().fromAngleAxis(0, Vector3f.UNIT_Y)); 1.73 if (this.audioRenderer instanceof MultiListener){ 1.74 MultiListener rf = (MultiListener)this.audioRenderer; 1.75 1.76 @@ -343,30 +347,40 @@ 1.77 private int countdown = 0; 1.78 1.79 public void simpleUpdate(float tpf) { 1.80 + if (countdown == 0){ 1.81 + music.play(); 1.82 + } 1.83 //Vector3f loc = cam.getLocation(); 1.84 //Quaternion rot = cam.getRotation(); 1.85 //listener.setLocation(loc); 1.86 - //listener.setRotation(rot); 1.87 + listener.setRotation(new Quaternion().fromAngleAxis(0, music.getLocalTranslation().subtract(listener.getLocation()))); 1.88 + audioRenderer.updateListenerParam(listener, ListenerParam.Rotation); 1.89 + 1.90 System.out.println(countdown); 1.91 - if (countdown++ == 400) { this.requestClose(false);} 1.92 1.93 - System.out.println("channel "+ music.getChannel()); 1.94 + if (countdown++ == 700) { this.requestClose(false);} 1.95 + 1.96 + //System.out.println("channel "+ music.getChannel()); 1.97 //listener.setLocation(cam.getLocation()); 1.98 //listener.setRotation(cam.getRotation()); 1.99 //auxListener.setLocation(loc); 1.100 //auxListener.setRotation(rot); 1.101 - if (music.getStatus() != AudioNode.Status.Playing){ 1.102 + //if (music.getStatus() != AudioNode.Status.Playing){ 1.103 //audioRenderer.playSource(music); 1.104 - music.play(); 1.105 - bell.getMaterial().setColor("Color", ColorRGBA.randomColor()); 1.106 - System.out.println("I'm playing! <3"); 1.107 - } 1.108 + //music.play(); 1.109 + // bell.getMaterial().setColor("Color", ColorRGBA.randomColor()); 1.110 + //System.out.println("I'm playing! <3"); 1.111 + //} 1.112 //audioRenderer.updateSourceParam(music, AudioParam.Direction); 1.113 1.114 //Vector3f bellVelocity = bell.getLocalTranslation().subtract(prevBellPos).mult(1.0f/tpf); 1.115 //prevBellPos = bell.getLocalTranslation(); 1.116 1.117 music.setLocalTranslation(bell.getLocalTranslation()); 1.118 + 1.119 + System.out.println("distance: " + 1.120 + music.getLocalTranslation().subtract(listener.getLocation()).length()); 1.121 + 1.122 //music.setVelocity(bellVelocity); 1.123 1.124 //audioRenderer.updateSourceParam(music, AudioParam.Position);