Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (753)
Games in Android Showcase (228)
games submitted by our members
Games in WIP (842)
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 1493 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
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
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;
    }


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

stb_vorbis_get_samples_short_interleaved


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

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

OggReader.java  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
stb_vorbis_get_samples_short_interleaved
is fed into
alBufferData
directly with an
AL_FORMAT_STEREO16
format.

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  
 
 

 
ivj94 (579 views)
2018-03-24 14:47:39

ivj94 (42 views)
2018-03-24 14:46:31

ivj94 (346 views)
2018-03-24 14:43:53

Solater (59 views)
2018-03-17 05:04:08

nelsongames (104 views)
2018-03-05 17:56:34

Gornova (122 views)
2018-03-02 22:15:33

buddyBro (665 views)
2018-02-28 16:59:18

buddyBro (89 views)
2018-02-28 16:45:17

xxMrPHDxx (491 views)
2017-12-31 17:17:51

xxMrPHDxx (727 views)
2017-12-31 17:15:51
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org 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‑gaming.org
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!