# HG changeset patch # User Robert McIntyre # Date 1319994398 25200 # Node ID 9f58273090df2de7955996525130014f170f2657 # Parent 95648b0c12bc87a132f19d989bf60e37e7f58ae7 added AudioFormat to AudioSendRenderer diff -r 95648b0c12bc -r 9f58273090df src/com/aurellem/capture/audio/AudioSendRenderer.java --- a/src/com/aurellem/capture/audio/AudioSendRenderer.java Sun Oct 30 04:43:39 2011 -0700 +++ b/src/com/aurellem/capture/audio/AudioSendRenderer.java Sun Oct 30 10:06:38 2011 -0700 @@ -8,6 +8,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import javax.sound.sampled.AudioFormat; + import org.lwjgl.LWJGLException; import org.lwjgl.openal.AL; import org.lwjgl.openal.AL10; @@ -25,6 +27,7 @@ extends LwjglAudioRenderer implements MultiListener { private AudioSend audioSend; + private static final AudioFormat outFormat = new AudioFormat(44100.0f, 32, 1, true, false); /** * Keeps track of all the listeners which have been registered so far. @@ -102,7 +105,7 @@ public void initInThread(){ try{ if (!AL.isCreated()){ - AL.create("Multiple Audio Send", 44100, 60, false); + AL.create("Multiple Audio Send", (int) outFormat.getSampleRate(), 60, false); } }catch (OpenALException ex){ logger.log(Level.SEVERE, "Failed to load audio library", ex); @@ -166,11 +169,11 @@ } - public final static int BYTES_PER_SAMPLE = 4; + //public final static int BYTES_PER_SAMPLE = 4; private ByteBuffer buffer = BufferUtils.createByteBuffer(4096); public void dispatchAudio(float tpf){ - int samplesToGet = (int) (tpf * 44100); + int samplesToGet = (int) (tpf * outFormat.getSampleRate()); try {latch.await();} catch (InterruptedException e) {e.printStackTrace();} audioSend.step(samplesToGet); @@ -181,7 +184,7 @@ audioSend.getSamples(buffer, samplesToGet, i); SoundProcessor sp = this.soundProcessorMap.get(this.listeners.get(i)); - if (null != sp){sp.process(buffer, samplesToGet*BYTES_PER_SAMPLE);} + if (null != sp){sp.process(buffer, samplesToGet*outFormat.getFrameSize());} } }