# HG changeset patch # User Robert McIntyre # Date 1320072224 25200 # Node ID adeb887876458ea94e63d19ff81e48141723ad77 # Parent 094a92b556a258c4bb015f9806f47bbb7abd0a89 fixed all problems for 16 bit mono output diff -r 094a92b556a2 -r adeb88787645 divergence/results.txt --- a/divergence/results.txt Mon Oct 31 02:35:35 2011 -0700 +++ b/divergence/results.txt Mon Oct 31 07:43:44 2011 -0700 @@ -5,7 +5,6 @@ sqr-100Hz also diverges at 10. - calling audioRenderer.updateSourceParams in main update loop doesn't change output @@ -33,7 +32,6 @@ Divergence gets worse the longer things run. - As the sound source moves about the listener in a circle, the sound should be at a constant volume, since the distance between the source and listener is constant. Instead, the sound varies depending on where diff -r 094a92b556a2 -r adeb88787645 src/com/aurellem/capture/audio/AudioSendRenderer.java --- a/src/com/aurellem/capture/audio/AudioSendRenderer.java Mon Oct 31 02:35:35 2011 -0700 +++ b/src/com/aurellem/capture/audio/AudioSendRenderer.java Mon Oct 31 07:43:44 2011 -0700 @@ -27,7 +27,7 @@ extends LwjglAudioRenderer implements MultiListener { private AudioSend audioSend; - private static final AudioFormat outFormat = new AudioFormat(44100.0f, 32, 1, true, false); + private AudioFormat outFormat;// = new AudioFormat(44100.0f, 32, 1, true, false); /** * Keeps track of all the listeners which have been registered so far. @@ -106,7 +106,7 @@ public void initInThread(){ try{ if (!AL.isCreated()){ - AL.create("Multiple Audio Send", (int) outFormat.getSampleRate(), 60, false); + AL.create("Multiple Audio Send", 44100, 60, false); } }catch (OpenALException ex){ logger.log(Level.SEVERE, "Failed to load audio library", ex); @@ -134,6 +134,9 @@ catch (NoSuchFieldException e) {e.printStackTrace();} this.audioSend = new AudioSend(this.deviceID); + this.outFormat = audioSend.getAudioFormat(); + initBuffer(); + System.out.println(outFormat); // The LWJGL context must be established as the master context before // any other listeners can be created on this device. @@ -171,15 +174,29 @@ //public final static int BYTES_PER_SAMPLE = 4; - private ByteBuffer buffer = BufferUtils.createByteBuffer(4096); - private byte[] debug0 = new byte[4096]; - private byte[] debug1 = new byte[4096]; + private ByteBuffer buffer;; + private byte[] debug0; + private byte[] debug1; + public static final int MIN_FRAMERATE = 10; + + private void initBuffer(){ + int bufferSize = (int)(this.outFormat.getSampleRate() / ((float)MIN_FRAMERATE)) * + this.outFormat.getFrameSize(); + this.buffer = BufferUtils.createByteBuffer(bufferSize); + debug0 = new byte[4096]; + debug1 = new byte[4096]; + + } + /* + + */ public void dispatchAudio(float tpf){ int samplesToGet = (int) (tpf * outFormat.getSampleRate()); + System.out.println("want " + samplesToGet + " samples"); try {latch.await();} catch (InterruptedException e) {e.printStackTrace();} audioSend.step(samplesToGet); diff -r 094a92b556a2 -r adeb88787645 src/com/aurellem/capture/examples/AdvancedAudio.java --- a/src/com/aurellem/capture/examples/AdvancedAudio.java Mon Oct 31 02:35:35 2011 -0700 +++ b/src/com/aurellem/capture/examples/AdvancedAudio.java Mon Oct 31 07:43:44 2011 -0700 @@ -208,16 +208,16 @@ music = new AudioNode(assetManager, "Sound/Environment/sqr-1kHz.wav", false); rootNode.attachChild(music); - //audioRenderer.playSource(music); - //music.setPositional(true); - //music.setVolume(1f); - //music.setReverbEnabled(false); - //music.setDirectional(false); - //music.setMaxDistance(200.0f); - //music.setRefDistance(1f); - //music.setRolloffFactor(1f); - //music.setLooping(false); - //audioRenderer.pauseSource(music); + audioRenderer.playSource(music); + music.setPositional(true); + music.setVolume(1f); + music.setReverbEnabled(false); + music.setDirectional(false); + music.setMaxDistance(200.0f); + music.setRefDistance(1f); + music.setRolloffFactor(1f); + music.setLooping(false); + audioRenderer.pauseSource(music); } @@ -358,7 +358,7 @@ System.out.println(countdown); - if (countdown++ == 700) { this.requestClose(false);} + if (countdown++ == 300) { this.requestClose(false);} //System.out.println("channel "+ music.getChannel()); //listener.setLocation(cam.getLocation());