diff src/com/aurellem/capture/examples/AdvancedAudio.java @ 34:13d354e1184b

trying to track down very strange bug where a listener and aux listener at the same location hear different things
author Robert McIntyre <rlm@mit.edu>
date Sun, 30 Oct 2011 14:58:01 -0700
parents c4bfbf5d090e
children c969b04fa0dc
line wrap: on
line diff
     1.1 --- a/src/com/aurellem/capture/examples/AdvancedAudio.java	Sun Oct 30 13:57:16 2011 -0700
     1.2 +++ b/src/com/aurellem/capture/examples/AdvancedAudio.java	Sun Oct 30 14:58:01 2011 -0700
     1.3 @@ -17,6 +17,7 @@
     1.4  import com.aurellem.capture.audio.WaveFileWriter;
     1.5  import com.jme3.app.SimpleApplication;
     1.6  import com.jme3.audio.AudioNode;
     1.7 +import com.jme3.audio.AudioParam;
     1.8  import com.jme3.audio.Listener;
     1.9  import com.jme3.cinematic.MotionPath;
    1.10  import com.jme3.cinematic.events.MotionTrack;
    1.11 @@ -206,11 +207,11 @@
    1.12      rootNode.attachChild(music);
    1.13      audioRenderer.playSource(music);
    1.14      music.setPositional(true);
    1.15 -    //music.setVolume(1f);
    1.16 -    
    1.17 -    //music.setMaxDistance(200.0f);
    1.18 -    //music.setRefDistance(0.1f);
    1.19 -    //music.setRolloffFactor(5f);
    1.20 +    music.setVolume(1f);
    1.21 +    music.setReverbEnabled(false);
    1.22 +    music.setMaxDistance(200.0f);
    1.23 +    music.setRefDistance(1f);
    1.24 +    music.setRolloffFactor(5f);
    1.25      audioRenderer.pauseSource(music); 
    1.26      
    1.27    }
    1.28 @@ -219,12 +220,12 @@
    1.29    
    1.30    
    1.31    private Listener auxListener = new Listener(); 
    1.32 -  public File data1 = new File("/home/r/tmp/data1.wav");
    1.33 -  public File data2 = new File("/home/r/tmp/data2.wav");
    1.34 -  public File data3 = new File("/home/r/tmp/data3.wav");
    1.35 -  public File data4 = new File("/home/r/tmp/data4.wav");
    1.36 -  public File data5 = new File("/home/r/tmp/data5.wav");
    1.37 -  public File data6 = new File("/home/r/tmp/data6.wav");
    1.38 +  //public File data1 = new File("/home/r/tmp/data1.wav");
    1.39 +  //public File data2 = new File("/home/r/tmp/data2.wav");
    1.40 +  //public File data3 = new File("/home/r/tmp/data3.wav");
    1.41 +  //public File data4 = new File("/home/r/tmp/data4.wav");
    1.42 +  //public File data5 = new File("/home/r/tmp/data5.wav");
    1.43 +  //public File data6 = new File("/home/r/tmp/data6.wav");
    1.44  
    1.45  
    1.46    public class Dancer implements SoundProcessor {
    1.47 @@ -258,7 +259,7 @@
    1.48  		  
    1.49  		  float max = Float.NEGATIVE_INFINITY;
    1.50  		  for (float f : out){if (f > max) max = f;}
    1.51 -		  
    1.52 +		  audioSamples.clear();
    1.53  		  System.out.println(debug);
    1.54  		  System.out.println(max);
    1.55  		  
    1.56 @@ -284,22 +285,25 @@
    1.57  		MultiListener rf = (MultiListener)this.audioRenderer;
    1.58  		
    1.59  		
    1.60 +		listener.setLocation(ear1.getLocalTranslation());
    1.61 +		auxListener = new Listener(listener);
    1.62 +		
    1.63  		rf.addListener(auxListener);
    1.64 -		WaveFileWriter writer = null;
    1.65 -		WaveFileWriter writer2 = null;
    1.66 -		auxListener.setLocation(ear1.getLocalTranslation());
    1.67 -		listener.setLocation(ear1.getLocalTranslation());
    1.68 -		try {writer = new WaveFileWriter(new File("/home/r/tmp/out.wav"));} 
    1.69 +		WaveFileWriter aux = null;
    1.70 +		WaveFileWriter main = null;
    1.71 +
    1.72 +		
    1.73 +		try {aux = new WaveFileWriter(new File("/home/r/tmp/aux.wav"));} 
    1.74  		catch (FileNotFoundException e) {e.printStackTrace();}
    1.75  		
    1.76 -		try {writer2 = new WaveFileWriter(new File("/home/r/tmp/outmain.wav"));} 
    1.77 +		try {main = new WaveFileWriter(new File("/home/r/tmp/main.wav"));} 
    1.78  		catch (FileNotFoundException e) {e.printStackTrace();}
    1.79  				
    1.80  		rf.registerSoundProcessor(auxListener, 
    1.81 -				new CompositeSoundProcessor(new Dancer(ear1, "aux"), writer));
    1.82 +				new CompositeSoundProcessor(new Dancer(ear1, "aux"), aux));
    1.83  		
    1.84  		rf.registerSoundProcessor(
    1.85 -				new CompositeSoundProcessor(new Dancer(ear1, "main"), writer2));
    1.86 +				new CompositeSoundProcessor(new Dancer(ear1, "--------\nmain"), main));
    1.87  	}   
    1.88  
    1.89      motionControl.play();
    1.90 @@ -358,6 +362,12 @@
    1.91      music.setLocalTranslation(bell.getLocalTranslation());
    1.92      music.setVelocity(bellVelocity);
    1.93      
    1.94 +    //audioRenderer.updateSourceParam(music, AudioParam.Position);
    1.95 +    //audioRenderer.updateSourceParam(music, AudioParam.Velocity);
    1.96 +    
    1.97 +    
    1.98 +    //System.out.println("main:" + listener.getVolume());
    1.99 +    //System.out.println("aux:" + auxListener.getVolume());
   1.100      //org.lwjgl.openal.AL10.alSourcef(1, org.lwjgl.openal.AL10.AL_MIN_GAIN, 0f);
   1.101      //org.lwjgl.openal.AL10.alSourcef(1, org.lwjgl.openal.AL10.AL_ROLLOFF_FACTOR, 5f);
   1.102