javalwjgloggvorbis

How to decode ogg vorbis file java?


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.


Solution

  • 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?