Mercurial > jmeCapture
diff src/com/aurellem/capture/audio/AudioSendRenderer.java @ 27:5249c8a9603c
changed SoundProcessors to use AudioFormat
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 30 Oct 2011 08:10:26 -0700 |
parents | 8a6b1684f536 |
children | 7184bc09a92e |
line wrap: on
line diff
1.1 --- a/src/com/aurellem/capture/audio/AudioSendRenderer.java Sun Oct 30 04:43:39 2011 -0700 1.2 +++ b/src/com/aurellem/capture/audio/AudioSendRenderer.java Sun Oct 30 08:10:26 2011 -0700 1.3 @@ -8,6 +8,8 @@ 1.4 import java.util.logging.Level; 1.5 import java.util.logging.Logger; 1.6 1.7 +import javax.sound.sampled.AudioFormat; 1.8 + 1.9 import org.lwjgl.LWJGLException; 1.10 import org.lwjgl.openal.AL; 1.11 import org.lwjgl.openal.AL10; 1.12 @@ -25,6 +27,7 @@ 1.13 extends LwjglAudioRenderer implements MultiListener { 1.14 1.15 private AudioSend audioSend; 1.16 + public static final AudioFormat outputFormat = new AudioFormat(44100.0f, 32, 1, true, false); 1.17 1.18 /** 1.19 * Keeps track of all the listeners which have been registered so far. 1.20 @@ -102,8 +105,7 @@ 1.21 public void initInThread(){ 1.22 try{ 1.23 if (!AL.isCreated()){ 1.24 - AL.create("Multiple Audio Send", 44100, 60, false); 1.25 - } 1.26 + AL.create("Multiple Audio Send", (int)outputFormat.getSampleRate(), 60, false); } 1.27 }catch (OpenALException ex){ 1.28 logger.log(Level.SEVERE, "Failed to load audio library", ex); 1.29 System.exit(1); 1.30 @@ -166,11 +168,11 @@ 1.31 } 1.32 1.33 1.34 - public final static int BYTES_PER_SAMPLE = 4; 1.35 + 1.36 private ByteBuffer buffer = BufferUtils.createByteBuffer(4096); 1.37 1.38 public void dispatchAudio(float tpf){ 1.39 - int samplesToGet = (int) (tpf * 44100); 1.40 + int samplesToGet = (int) (tpf * outputFormat.getSampleRate()); 1.41 try {latch.await();} 1.42 catch (InterruptedException e) {e.printStackTrace();} 1.43 audioSend.step(samplesToGet); 1.44 @@ -181,7 +183,8 @@ 1.45 audioSend.getSamples(buffer, samplesToGet, i); 1.46 SoundProcessor sp = 1.47 this.soundProcessorMap.get(this.listeners.get(i)); 1.48 - if (null != sp){sp.process(buffer, samplesToGet*BYTES_PER_SAMPLE);} 1.49 + if (null != sp){sp.process(buffer, outputFormat, 1.50 + samplesToGet*outputFormat.getSampleSizeInBits()/8);} 1.51 } 1.52 1.53 }