Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (780)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  OpenAL - 2 channel OGG sound  (Read 1883 times)
0 Members and 1 Guest are viewing this topic.
Offline KudoDEV

JGO Ninja

Medals: 79
Exp: 6 years

Game Dev Hobbyist

« Posted 2015-09-04 18:21:30 »

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()) {

        return dest;

Offline ziozio
« Reply #1 - Posted 2015-09-04 20:42:10 »

openal uses pcm format, how are you converting ogg in to pcm? Are you doing all of channel1 then channel2 or are you interleaving them?
Offline KudoDEV

JGO Ninja

Medals: 79
Exp: 6 years

Game Dev Hobbyist

« Reply #2 - Posted 2015-09-05 17:59:51 »

It's interleaved into 1 bytebuffer using


Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SHC
« Reply #3 - Posted 2015-09-05 18:05:18 »

This is how I do using STB_Vorbis, and it works fine for me.  ISoundReader

I think it would be better if you post what OpenAL error you are getting.

Offline Spasi
« Reply #4 - Posted 2015-09-06 10:54:18 »

Why are you using that convertAudioBytes method? Is that from LWJGL 2?

OpenAL can play interleaved-stereo short samples directly. See the Vorbis player sample in the LWJGL 3 repository. The result of
is fed into
directly with an

edit: the latest stb_vorbis supports seeking now, I have updated the sample (use left/right keys or drag with the mouse).
Offline KudoDEV

JGO Ninja

Medals: 79
Exp: 6 years

Game Dev Hobbyist

« Reply #5 - Posted 2015-09-06 14:27:35 »

@Spasi That's what I figured. I was just fishing when I found that snippet. But no there is no sound when an ogg has 2 channels. There is sound when I convert that same file to mono. Going to check out the new example now.

@SHC Thanks. That helps

Edit: It has something to do with the file itself. I downloaded the original sound from youtube. Sounds from other sources work fine in stereo.

Thanks again guys.

Offline KudoDEV

JGO Ninja

Medals: 79
Exp: 6 years

Game Dev Hobbyist

« Reply #6 - Posted 2015-09-06 17:30:32 »

Confirmed. It was a conversion issue. From MP3 to OGG. Decided to start using FLAC instead. Then converting to OGG.

Pages: [1]
  ignore  |  Print  

hadezbladez (696 views)
2018-11-16 13:46:03

hadezbladez (344 views)
2018-11-16 13:41:33

hadezbladez (678 views)
2018-11-16 13:35:35

hadezbladez (169 views)
2018-11-16 13:32:03

EgonOlsen (2362 views)
2018-06-10 19:43:48

EgonOlsen (2474 views)
2018-06-10 19:43:44

EgonOlsen (1463 views)
2018-06-10 19:43:20

DesertCoockie (2128 views)
2018-05-13 18:23:11

nelsongames (1904 views)
2018-04-24 18:15:36

nelsongames (2571 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!