From my understanding when there is 1 channel we use the format AL_FORMAT_MONO16
when there are 2 we use AL_FORMAT_STEREO16.
Currently sounds with one channel work perfectly. However sounds with 2 channels throw no errors when uploaded and don’t play.
They do play in the AL_FORMAT_MONO16 format, but it’s all messed up.
Has anyone ran into this issue? There is not much info online about this.
I think it might be this bit of code: (changed it a bit)
It throws an error if I use rewind instead of flip. It had rewind in the original source. OpenAL errors aren’t very descriptive.
honestly it looks silly to me, or missing something. However this is what I found as an official LWJGL example
private static ByteBuffer convertAudioBytes(ByteBuffer samples, boolean stereo) {
if (!stereo) {
return samples;
}
ByteBuffer dest = BufferUtils.createByteBuffer(samples.capacity());
ShortBuffer dest_short = dest.asShortBuffer();
ShortBuffer src_short = samples.asShortBuffer();
while (src_short.hasRemaining()) {
dest_short.put(src_short.get());
}
dest.flip();
return dest;
}