*** empty log message ***

This commit is contained in:
Elias Naur 2003-10-22 11:33:01 +00:00
parent 561f3cff10
commit 931f15f27f
1 changed files with 61 additions and 40 deletions

View File

@ -34,6 +34,8 @@ package org.lwjgl.test.openal;
import org.lwjgl.openal.AL;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.nio.ByteOrder;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
@ -164,9 +166,10 @@ public class WaveData {
}
//insert data into bytebuffer
ByteBuffer buffer = ByteBuffer.allocateDirect(buf.length);
ByteBuffer buffer = convertAudioBytes(buf, audioformat.getSampleSizeInBits() == 16);
/* ByteBuffer buffer = ByteBuffer.allocateDirect(buf.length);
buffer.put(buf);
buffer.rewind();
buffer.rewind();*/
//create our result
WaveData wavedata =
@ -180,4 +183,22 @@ public class WaveData {
return wavedata;
}
private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data) {
ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
dest.order(ByteOrder.nativeOrder());
ByteBuffer src = ByteBuffer.wrap(audio_bytes);
src.order(ByteOrder.LITTLE_ENDIAN);
if (two_bytes_data) {
ShortBuffer dest_short = dest.asShortBuffer();
ShortBuffer src_short = src.asShortBuffer();
while (src_short.hasRemaining())
dest_short.put(src_short.get());
} else {
while (src.hasRemaining())
dest.put(src.get());
}
dest.rewind();
return dest;
}
}