Mercurial > jmeCapture
diff src/com/aurellem/capture/examples/AdvancedAudio.java @ 35:c969b04fa0dc
working on divergence
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 31 Oct 2011 00:14:46 -0700 |
parents | 13d354e1184b |
children | 2a525e937d86 |
line wrap: on
line diff
1.1 --- a/src/com/aurellem/capture/examples/AdvancedAudio.java Sun Oct 30 14:58:01 2011 -0700 1.2 +++ b/src/com/aurellem/capture/examples/AdvancedAudio.java Mon Oct 31 00:14:46 2011 -0700 1.3 @@ -4,6 +4,8 @@ 1.4 import java.io.FileNotFoundException; 1.5 import java.io.IOException; 1.6 import java.nio.ByteBuffer; 1.7 +import java.util.logging.Level; 1.8 +import java.util.logging.Logger; 1.9 1.10 import javax.sound.sampled.AudioFormat; 1.11 1.12 @@ -59,7 +61,7 @@ 1.13 public class AdvancedAudio extends SimpleApplication { 1.14 1.15 public static void main(String[] args) { 1.16 - 1.17 + Logger.getLogger("com.jme3").setLevel(Level.OFF); 1.18 AdvancedAudio app = new AdvancedAudio(); 1.19 AppSettings settings = new AppSettings(true); 1.20 settings.setAudioRenderer("Send"); 1.21 @@ -205,14 +207,16 @@ 1.22 music = new AudioNode(assetManager, "Sound/Environment/pure.wav", false); 1.23 1.24 rootNode.attachChild(music); 1.25 - audioRenderer.playSource(music); 1.26 + //audioRenderer.playSource(music); 1.27 music.setPositional(true); 1.28 music.setVolume(1f); 1.29 music.setReverbEnabled(false); 1.30 music.setMaxDistance(200.0f); 1.31 music.setRefDistance(1f); 1.32 music.setRolloffFactor(5f); 1.33 - audioRenderer.pauseSource(music); 1.34 + 1.35 + 1.36 + //audioRenderer.pauseSource(music); 1.37 1.38 } 1.39 1.40 @@ -281,11 +285,12 @@ 1.41 initAudio(); 1.42 initKeys(); 1.43 createScene(); 1.44 + listener.setLocation(ear1.getLocalTranslation()); 1.45 if (this.audioRenderer instanceof MultiListener){ 1.46 MultiListener rf = (MultiListener)this.audioRenderer; 1.47 1.48 1.49 - listener.setLocation(ear1.getLocalTranslation()); 1.50 + 1.51 auxListener = new Listener(listener); 1.52 1.53 rf.addListener(auxListener); 1.54 @@ -323,10 +328,10 @@ 1.55 @Override 1.56 public void onAction(String name, boolean keyPressed, float tpf) { 1.57 if (name.equals("Shoot") && !keyPressed) { 1.58 - System.out.println("I'm playing! <3"); 1.59 - System.out.println(bell.getLocalTranslation().subtract(cam.getLocation()).length()); 1.60 - bell.getMaterial().setColor("Color", ColorRGBA.randomColor()); 1.61 - audioRenderer.playSource(music); 1.62 + 1.63 + System.out.println(bell.getLocalTranslation().subtract(listener.getLocation()).length()); 1.64 + //bell.getMaterial().setColor("Color", ColorRGBA.randomColor()); 1.65 + //audioRenderer.playSource(music); 1.66 System.out.println(music.getRefDistance()); 1.67 1.68 } 1.69 @@ -336,31 +341,35 @@ 1.70 /** Move the listener with the camera - for 3D audio. */ 1.71 1.72 1.73 - private Vector3f prevBellPos = Vector3f.ZERO; 1.74 - 1.75 + //private Vector3f prevBellPos = Vector3f.ZERO; 1.76 + private int countdown = 0; 1.77 1.78 public void simpleUpdate(float tpf) { 1.79 //Vector3f loc = cam.getLocation(); 1.80 //Quaternion rot = cam.getRotation(); 1.81 //listener.setLocation(loc); 1.82 //listener.setRotation(rot); 1.83 + System.out.println(countdown); 1.84 + if (countdown++ == 14) { this.requestClose(false);} 1.85 1.86 - 1.87 + System.out.println("channel "+ music.getChannel()); 1.88 //listener.setLocation(cam.getLocation()); 1.89 //listener.setRotation(cam.getRotation()); 1.90 //auxListener.setLocation(loc); 1.91 //auxListener.setRotation(rot); 1.92 if (music.getStatus() != AudioNode.Status.Playing){ 1.93 - audioRenderer.playSource(music); 1.94 + //audioRenderer.playSource(music); 1.95 + music.play(); 1.96 bell.getMaterial().setColor("Color", ColorRGBA.randomColor()); 1.97 + System.out.println("I'm playing! <3"); 1.98 } 1.99 //audioRenderer.updateSourceParam(music, AudioParam.Direction); 1.100 1.101 - Vector3f bellVelocity = bell.getLocalTranslation().subtract(prevBellPos).mult(1.0f/tpf); 1.102 - prevBellPos = bell.getLocalTranslation(); 1.103 + //Vector3f bellVelocity = bell.getLocalTranslation().subtract(prevBellPos).mult(1.0f/tpf); 1.104 + //prevBellPos = bell.getLocalTranslation(); 1.105 1.106 music.setLocalTranslation(bell.getLocalTranslation()); 1.107 - music.setVelocity(bellVelocity); 1.108 + //music.setVelocity(bellVelocity); 1.109 1.110 //audioRenderer.updateSourceParam(music, AudioParam.Position); 1.111 //audioRenderer.updateSourceParam(music, AudioParam.Velocity);