Hello Guest

How to play OGG and/or MP3 with OpenAL?

  • 3 Replies
  • 2879 Views
How to play OGG and/or MP3 with OpenAL?
« 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?

*

Kai

Re: How to play OGG and/or MP3 with OpenAL?
« Reply #1 on: September 14, 2016, 12:12:25 »
LWJGL 3 can directly decode Ogg Vorbis to PCM, via the org.lwjgl.stb.STBVorbis class.

*

Offline spasi

  • *****
  • 2009
    • WebHotelier
Re: How to play OGG and/or MP3 with OpenAL?
« Reply #2 on: September 14, 2016, 12:53:43 »
A tutorial that describes how to stream OGG would be really nice

This demo does stream decoding and playback of an Ogg Vorbis file.

Re: How to play OGG and/or MP3 with OpenAL?
« Reply #3 on: September 14, 2016, 15:36:37 »

This demo 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.