Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
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 1780 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
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.

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  
 
 

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

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

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

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

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

nelsongames (1716 views)
2018-04-24 18:14:32

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

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

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

Solater (972 views)
2018-03-17 05:04:08
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
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!