Mercurial > jmeCapture
changeset 29:9f58273090df
added AudioFormat to AudioSendRenderer
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 30 Oct 2011 10:06:38 -0700 |
parents | 95648b0c12bc |
children | be37291c62b8 |
files | src/com/aurellem/capture/audio/AudioSendRenderer.java |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
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 10:06:38 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 + private static final AudioFormat outFormat = 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,7 +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 + AL.create("Multiple Audio Send", (int) outFormat.getSampleRate(), 60, false); 1.26 } 1.27 }catch (OpenALException ex){ 1.28 logger.log(Level.SEVERE, "Failed to load audio library", ex); 1.29 @@ -166,11 +169,11 @@ 1.30 } 1.31 1.32 1.33 - public final static int BYTES_PER_SAMPLE = 4; 1.34 + //public final static int BYTES_PER_SAMPLE = 4; 1.35 private ByteBuffer buffer = BufferUtils.createByteBuffer(4096); 1.36 1.37 public void dispatchAudio(float tpf){ 1.38 - int samplesToGet = (int) (tpf * 44100); 1.39 + int samplesToGet = (int) (tpf * outFormat.getSampleRate()); 1.40 try {latch.await();} 1.41 catch (InterruptedException e) {e.printStackTrace();} 1.42 audioSend.step(samplesToGet); 1.43 @@ -181,7 +184,7 @@ 1.44 audioSend.getSamples(buffer, samplesToGet, i); 1.45 SoundProcessor sp = 1.46 this.soundProcessorMap.get(this.listeners.get(i)); 1.47 - if (null != sp){sp.process(buffer, samplesToGet*BYTES_PER_SAMPLE);} 1.48 + if (null != sp){sp.process(buffer, samplesToGet*outFormat.getFrameSize());} 1.49 } 1.50 1.51 }