Hello Guest

Ogg Vorbis Support?

  • 15 Replies
  • 32207 Views
Ogg Vorbis Support?
« on: April 01, 2005, 23:36:55 »
I heard a while back that OpenAL was talking about including Ogg Vorbis support... has this happened yet?

If it has, could someone please show off a simple code snipet as to how one should (as in, the "right way") load an Ogg Vorbis file and play it via OpenAL. I can't find info on this stuff anywhere. I've been using JOrbis, but would love to drop it for straight OpenAL.

Thanks.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Ogg Vorbis Support?
« Reply #1 on: April 02, 2005, 05:27:26 »
hello.

http://unixforge.org/~numberr/data/openal_test.tar.bz2
this is a sample that uses ogg vorbis support from OpenAL. in fact, this sample does not require jorbis or other library to play ogg vorbis audio. it's just a little bit of modification of samples that i found when i was looking for lwjgl sample to play ogg vorbis with lwjgl. thanks for authors of the samples.

the sample includes libopengl.so, with ogg vorbis support enabled, but i figured out back then that OpenAL can support mp3 as well, if you compile it with smpeg. i think it's not good idea to distribute mp3 playback enabled libopengl.so, but good to know. it's really easy to compile OpenAL, so visit OpenGL CVS and you'll be okay.

the sample runs fine on Linux, but i don't know how to compile OpenAL on windows,
sorry if you want to run it on windows, but code could be used for windows as well.
only thing you need is OpenAL library with vorbis enabled for windows.

Ogg Vorbis Support?
« Reply #2 on: April 02, 2005, 23:19:16 »
Thanks. I was trying to get it working on Windows until I realized that Ogg Vorbis support hadn't been built into the dll. Is the openal dll that's included with LWJGL replaceable? Can you switch it out with an official OpenAL dll?

Also, if Ogg isn't included by default with openAL, does that mean it's still beta?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

*

Offline Matzon

  • *****
  • 2242
Ogg Vorbis Support?
« Reply #3 on: April 03, 2005, 01:35:04 »
yeah - just replace it with any real openal dll, and rename it to lwjglaudio.dll

*

Offline Matzon

  • *****
  • 2242
Ogg Vorbis Support?
« Reply #4 on: April 03, 2005, 08:22:50 »
Quote
The beta may be useful to you if you are just playing around, but for a serious app which you intend to distribute soon, I'd recommend using the Ogg Vorbis libraries directly (specifically, I'd recommend the VorbisFile library, which is sufficient for most OpenAL uses and has a really simple interface).

We're working on complete Ogg Vorbis support across the board, but it isn't done yet (and unfortunately the beta codebase is being mostly thrown out due to issues not related to OV -- it was an experiment which failed).

http://opensource.creative.com/pipermail/openal/2005-March/002753.html

Ogg Vorbis Support?
« Reply #5 on: April 03, 2005, 22:41:25 »
thanks for the link. i was having hard time looking for OpenAL.dll with ogg vorbis enabled, and figured out it's really in beta phase for windows. i've also heard it's coming in summer of this year, but who knows.

except for playing wav files, jorbis or fmod is a way to go at this moment, i guess.

Ogg Vorbis Support?
« Reply #6 on: April 04, 2005, 15:00:54 »
Hmmm, so, if Ogg Vorbis is still basically non-supported by OpenAL, should I stick with the JOrbis library?

I originally programmed my game to use JOrbis for playing the background music. Only problem was, I needed to "stream" the music (via an InputStream)... and as I was watching the memory usage, it just kept going up and up. Then, when the music restarted (looped), the memory wouldn't clear (even though I cleared out all the openAL and byte buffers) and continued going up. The only way I could find that would clear up the memory was to manually call System.gc().

What's the best way to handle background music? I've got a MIDI object ready to go, but I don't like the way MIDI is handled in Java (not to mention, controlling things like volume by using the synthesizer and midichannels doesn't seem to work anymore). Is the Ogg Vorbis memory usage normal for inputstreams?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

*

Offline tomb

  • ***
  • 148
Ogg Vorbis Support?
« Reply #7 on: April 04, 2005, 23:58:14 »
How did you use this "InputStream"? Can't remember that JOrbis supported streaming by InputStream. That was why I created OggInputStream.

Your memory problems can either be that the vm think its got plenty of free heap space and don't bother to clean it up. How much memory are we talking about? The other possibilite is that your leaking direct memroy. That can be a problem as it is not garbage collected the same way as the heap memory.

Ogg Vorbis Support?
« Reply #8 on: April 05, 2005, 14:38:09 »
Ready for this? I'm using a slightly modified version of your stuff Tomb (thank you, thank you).  :P
I say an "InputStream" because first I open an InputStream for the file, and then call the OggInputStream(InputStream) constructor.

I'm really wondering if Java just feels like it doesn't need to clean things up, since when I run a System.gc(), it DOES clean it up but causes the game to pause for a moment while it does so. I've tried rewriting the release() method so as to clean up every buffer and variable that the oggplayer class calls, but it still doesn't clear up the memory with the System.gc() call.

Basically, this is what I see... The game starts at using about 58mb of memory. When the background music begins, that usage starts climbing (we're talking about kbytes, not mb). It continues climbing until the music stops (at this point the memory usage is about the 58mb + the size of the ogg file). Then, when the music starts again (because it's looped), the memory starts climbing again.
I've tracked the memory through about 4 music loops. It's never cleared out between loops (and I'm being very good to call the release() function before each restart), it just keeps going up. Of course, the machine I'm on has plenty of memory to spare, so could it just be the JVM being smart?

BTW, I had to stop using the playinthread() method after the last release of lwjgl... For some reason, it would crash when calling release() or stop() (it looks like the thead continues polling update() even though the buffers have been destroyed). Could calling the update() function manually in my game loop be causing this?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Ogg Vorbis Support?
« Reply #9 on: April 05, 2005, 20:55:03 »
Just for an update:
I've been doing quite a bit of testing with this. It looks like it's got to be a JVM memory management thing, as when I switched back to the threaded player, the memory was managed FAR better. I went ahead and tweaked around with the code some more and added a check to the update() method so that it'll check to see if the buffers have already been released or not before it tries to do anything with them.

With the playInNewThread() method, the memory will go up, but almost immediately come back down. Don't know why I didn't just try to fix it in the first place - I think I was just worried about using multiple threads along with lwjgl. It seems to do fine though so long as you remove the MAX_PRIORITY setting.  :wink:
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

*

Offline tomb

  • ***
  • 148
Ogg Vorbis Support?
« Reply #10 on: April 05, 2005, 22:10:26 »
The OggPlayer has got some problems, I know :( It is meant to be more of a test, than something that you would actually use in your game.

I don't think you need to worry about the memory usage. It will be collected. It's just that you don't create enough garbage, so the gc justs waits.

Ogg Vorbis Support?
« Reply #11 on: April 05, 2005, 22:19:10 »
Quote
The OggPlayer has got some problems, I know

I actually think it's GREAT! If it weren't for your player, I would have been clueless as to how to stream the sound in the first place! Thank you!
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Ogg Vorbis Support?
« Reply #12 on: June 12, 2005, 10:30:16 »
Quote from: "numberR"
hello.

http://unixforge.org/~numberr/data/openal_test.tar.bz2
this is a sample that uses ogg vorbis support from OpenAL.
.....
..


Is it just me beeing stupid or?? Can't find any tool that will take that file for a valid archive?? Please point my lame ass in the right direction because this sounds extremely interesting and would make my game even less crappy!


[edit] Found a tool.. After first learning how to spell correctly, Google helped me out once again. But if anyone else needs it, here's a link:

http://www.zipzag.com/

- I'm not stupid, I just got a very low IQ!

Ogg Vorbis Support?
« Reply #13 on: March 21, 2006, 18:02:43 »
Hi,

'm getting the same kind of problems elias4444 had. The memory is steadily increasing in kbyte-steps to 3 - 12 mb and is cleaned up again. Is this really normal? Actually it should only increase by some kilobytes - or does JOrbis allocate this memory? The only thing i'm doing, is to play an Ogg file in an own thread.

@elias4444: could you send me a excerpt of your threaded streaming ogg-player? Maybe it will help me, to find the bug ...

Ogg Vorbis Support?
« Reply #14 on: March 21, 2006, 19:35:23 »
The best thing to do is go through and find what's not clearing out. I had to go back to the basics and read up on buffers and how they work. It's amazing what kind of memory you can hog up if you don't utilize buffers correctly. Try to initialize your buffers at the beginning, and resuse the same ones over and over again. Understand that as your buffer fills up, your memory usage will go up to, so once the song is done playing, make sure to clear out your buffer to free up the memory (and then reuse). Also, with Ogg stuff, it's generally better to buffer and play only a small portion at a time (iow, streaming), as the Jorbis stuff just translates it into standard WAV (which takes a large amount of memory).
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com