LWJGL Forum

Programming => OpenAL => Topic started by: kitfox on September 14, 2016, 11:45:42

Title: How to play OGG and/or MP3 with OpenAL?
Post by: kitfox on September 14, 2016, 11:45:42
I'm new to OpenAL and trying to figure out the best way to load and play audio files using it.  My stumbling block at the moment is trying to find classes that can read OGG or MP3 files so I can then send their sound data to the OpenAL API.  (I'd prefer to use this over WAV, since WAV veresions of my files are around 10 times larger.  Also, the WaveData class does not seem to be included with LWJGL 3).

A tutorial that describes how to stream OGG would be really nice, but just finding a decoder would be helpful too.  (Also, it would be great to find code with a nonrestrictive commercial license.  Something like Apache 2 or BSD).

Could anyone give this newbie some tips?
Title: Re: How to play OGG and/or MP3 with OpenAL?
Post by: Kai on September 14, 2016, 12:12:25
LWJGL 3 can directly decode Ogg Vorbis to PCM, via the org.lwjgl.stb.STBVorbis class.
Title: Re: How to play OGG and/or MP3 with OpenAL?
Post by: spasi on September 14, 2016, 12:53:43
Quote from: kitfox on September 14, 2016, 11:45:42A tutorial that describes how to stream OGG would be really nice

This demo (https://github.com/LWJGL/lwjgl3/blob/master/modules/core/src/test/java/org/lwjgl/demo/stb/Vorbis.java) does stream decoding and playback of an Ogg Vorbis file.
Title: Re: How to play OGG and/or MP3 with OpenAL?
Post by: kitfox on September 14, 2016, 15:36:37

This demo (https://github.com/LWJGL/lwjgl3/blob/master/modules/core/src/test/java/org/lwjgl/demo/stb/Vorbis.java) does stream decoding and playback of an Ogg Vorbis file.
[/quote]

Thanks.  This code has about two dozen lines that cause errors with the LWJGL 3 release, though.  I'll try to see if I can adapt it.