2

I'm getting started with lwjgl and openal, so I want to be able to decode an ogg vorbis file and play it with openal. My question is: how can I decode an ogg file from java, get the frequency, pcm data, etc. and send it over to openal so I can play it? I found jorbis to do this, but it seemed just too difficult to use, and the tutorials online are kinda messy. I was thinking of something like alutLoadWavFromFile but for ogg(and java).

Thanks!

EDIT: Ok, I'll clarify my question. I want to decode an ogg file. And then send the data to openal. But the only part I don't know how to do is the decoding part.

Community
  • 1
  • 1
twkmz
  • 419
  • 1
  • 6
  • 14
  • *"how can I decode an ogg file from java, get the frequency, pcm data, etc. and send it over to openal so I can play it?"* This is actually 5 questions. Please try to narrow it down. – Radiodef May 03 '15 at 23:51
  • that's right. Fixed it – twkmz May 04 '15 at 00:01
  • possible duplicate of [How can I decode OGG vorbis data from a ByteBuffer?](http://stackoverflow.com/questions/3987518/how-can-i-decode-ogg-vorbis-data-from-a-bytebuffer) – ioctlLR May 05 '15 at 12:29

1 Answers1

1

VorbisJava does exactly this. There is a reasonable example in the tools directory.

https://github.com/Gagravarr/VorbisJava/blob/master/tools/src/main/java/org/gagravarr/vorbis/tools/VorbisCommentTool.java

VorbisFile vf = new VorbisFile(new File(inFile));

Also, Java Sound API has an extensible service provider model. You can add OggVorbis as a provider.

See How can I decode OGG vorbis data from a ByteBuffer?

Community
  • 1
  • 1
jrwren
  • 17,465
  • 8
  • 35
  • 56