Mercurial > jmeCapture
comparison 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 |
comparison
equal
deleted
inserted
replaced
33:c4bfbf5d090e | 34:13d354e1184b |
---|---|
15 import com.aurellem.capture.audio.MultiListener; | 15 import com.aurellem.capture.audio.MultiListener; |
16 import com.aurellem.capture.audio.SoundProcessor; | 16 import com.aurellem.capture.audio.SoundProcessor; |
17 import com.aurellem.capture.audio.WaveFileWriter; | 17 import com.aurellem.capture.audio.WaveFileWriter; |
18 import com.jme3.app.SimpleApplication; | 18 import com.jme3.app.SimpleApplication; |
19 import com.jme3.audio.AudioNode; | 19 import com.jme3.audio.AudioNode; |
20 import com.jme3.audio.AudioParam; | |
20 import com.jme3.audio.Listener; | 21 import com.jme3.audio.Listener; |
21 import com.jme3.cinematic.MotionPath; | 22 import com.jme3.cinematic.MotionPath; |
22 import com.jme3.cinematic.events.MotionTrack; | 23 import com.jme3.cinematic.events.MotionTrack; |
23 import com.jme3.input.controls.ActionListener; | 24 import com.jme3.input.controls.ActionListener; |
24 import com.jme3.input.controls.MouseButtonTrigger; | 25 import com.jme3.input.controls.MouseButtonTrigger; |
204 music = new AudioNode(assetManager, "Sound/Environment/pure.wav", false); | 205 music = new AudioNode(assetManager, "Sound/Environment/pure.wav", false); |
205 | 206 |
206 rootNode.attachChild(music); | 207 rootNode.attachChild(music); |
207 audioRenderer.playSource(music); | 208 audioRenderer.playSource(music); |
208 music.setPositional(true); | 209 music.setPositional(true); |
209 //music.setVolume(1f); | 210 music.setVolume(1f); |
210 | 211 music.setReverbEnabled(false); |
211 //music.setMaxDistance(200.0f); | 212 music.setMaxDistance(200.0f); |
212 //music.setRefDistance(0.1f); | 213 music.setRefDistance(1f); |
213 //music.setRolloffFactor(5f); | 214 music.setRolloffFactor(5f); |
214 audioRenderer.pauseSource(music); | 215 audioRenderer.pauseSource(music); |
215 | 216 |
216 } | 217 } |
217 | 218 |
218 | 219 |
219 | 220 |
220 | 221 |
221 private Listener auxListener = new Listener(); | 222 private Listener auxListener = new Listener(); |
222 public File data1 = new File("/home/r/tmp/data1.wav"); | 223 //public File data1 = new File("/home/r/tmp/data1.wav"); |
223 public File data2 = new File("/home/r/tmp/data2.wav"); | 224 //public File data2 = new File("/home/r/tmp/data2.wav"); |
224 public File data3 = new File("/home/r/tmp/data3.wav"); | 225 //public File data3 = new File("/home/r/tmp/data3.wav"); |
225 public File data4 = new File("/home/r/tmp/data4.wav"); | 226 //public File data4 = new File("/home/r/tmp/data4.wav"); |
226 public File data5 = new File("/home/r/tmp/data5.wav"); | 227 //public File data5 = new File("/home/r/tmp/data5.wav"); |
227 public File data6 = new File("/home/r/tmp/data6.wav"); | 228 //public File data6 = new File("/home/r/tmp/data6.wav"); |
228 | 229 |
229 | 230 |
230 public class Dancer implements SoundProcessor { | 231 public class Dancer implements SoundProcessor { |
231 | 232 |
232 Spatial entity; | 233 Spatial entity; |
256 FloatSampleTools.byte2floatInterleaved(data, 0, out, 0, | 257 FloatSampleTools.byte2floatInterleaved(data, 0, out, 0, |
257 numSamples/format.getFrameSize(), format); | 258 numSamples/format.getFrameSize(), format); |
258 | 259 |
259 float max = Float.NEGATIVE_INFINITY; | 260 float max = Float.NEGATIVE_INFINITY; |
260 for (float f : out){if (f > max) max = f;} | 261 for (float f : out){if (f > max) max = f;} |
261 | 262 audioSamples.clear(); |
262 System.out.println(debug); | 263 System.out.println(debug); |
263 System.out.println(max); | 264 System.out.println(max); |
264 | 265 |
265 | 266 |
266 | 267 |
282 createScene(); | 283 createScene(); |
283 if (this.audioRenderer instanceof MultiListener){ | 284 if (this.audioRenderer instanceof MultiListener){ |
284 MultiListener rf = (MultiListener)this.audioRenderer; | 285 MultiListener rf = (MultiListener)this.audioRenderer; |
285 | 286 |
286 | 287 |
288 listener.setLocation(ear1.getLocalTranslation()); | |
289 auxListener = new Listener(listener); | |
290 | |
287 rf.addListener(auxListener); | 291 rf.addListener(auxListener); |
288 WaveFileWriter writer = null; | 292 WaveFileWriter aux = null; |
289 WaveFileWriter writer2 = null; | 293 WaveFileWriter main = null; |
290 auxListener.setLocation(ear1.getLocalTranslation()); | 294 |
291 listener.setLocation(ear1.getLocalTranslation()); | 295 |
292 try {writer = new WaveFileWriter(new File("/home/r/tmp/out.wav"));} | 296 try {aux = new WaveFileWriter(new File("/home/r/tmp/aux.wav"));} |
293 catch (FileNotFoundException e) {e.printStackTrace();} | 297 catch (FileNotFoundException e) {e.printStackTrace();} |
294 | 298 |
295 try {writer2 = new WaveFileWriter(new File("/home/r/tmp/outmain.wav"));} | 299 try {main = new WaveFileWriter(new File("/home/r/tmp/main.wav"));} |
296 catch (FileNotFoundException e) {e.printStackTrace();} | 300 catch (FileNotFoundException e) {e.printStackTrace();} |
297 | 301 |
298 rf.registerSoundProcessor(auxListener, | 302 rf.registerSoundProcessor(auxListener, |
299 new CompositeSoundProcessor(new Dancer(ear1, "aux"), writer)); | 303 new CompositeSoundProcessor(new Dancer(ear1, "aux"), aux)); |
300 | 304 |
301 rf.registerSoundProcessor( | 305 rf.registerSoundProcessor( |
302 new CompositeSoundProcessor(new Dancer(ear1, "main"), writer2)); | 306 new CompositeSoundProcessor(new Dancer(ear1, "--------\nmain"), main)); |
303 } | 307 } |
304 | 308 |
305 motionControl.play(); | 309 motionControl.play(); |
306 } | 310 } |
307 | 311 |
356 prevBellPos = bell.getLocalTranslation(); | 360 prevBellPos = bell.getLocalTranslation(); |
357 | 361 |
358 music.setLocalTranslation(bell.getLocalTranslation()); | 362 music.setLocalTranslation(bell.getLocalTranslation()); |
359 music.setVelocity(bellVelocity); | 363 music.setVelocity(bellVelocity); |
360 | 364 |
365 //audioRenderer.updateSourceParam(music, AudioParam.Position); | |
366 //audioRenderer.updateSourceParam(music, AudioParam.Velocity); | |
367 | |
368 | |
369 //System.out.println("main:" + listener.getVolume()); | |
370 //System.out.println("aux:" + auxListener.getVolume()); | |
361 //org.lwjgl.openal.AL10.alSourcef(1, org.lwjgl.openal.AL10.AL_MIN_GAIN, 0f); | 371 //org.lwjgl.openal.AL10.alSourcef(1, org.lwjgl.openal.AL10.AL_MIN_GAIN, 0f); |
362 //org.lwjgl.openal.AL10.alSourcef(1, org.lwjgl.openal.AL10.AL_ROLLOFF_FACTOR, 5f); | 372 //org.lwjgl.openal.AL10.alSourcef(1, org.lwjgl.openal.AL10.AL_ROLLOFF_FACTOR, 5f); |
363 | 373 |
364 } | 374 } |
365 | 375 |