FMOD and OpenAL.... Where to Start?

I’ve been using OpenGL for a long time, but I’ve surprisingly never put any sounds into it. Can anyone point me towards some tutorials and/or examples that use this feature?

I have no idea the benefits / differences between OpenAL and FMOD, but I have both sound effects and 2 minute looping background sounds. I’ve also got plenty of them. I was thinking OGG compression was best… can OpenAL read it?

I’ve been reading http://www.lwjgl.org/documentation_openal_01.php but it doesn’t compare OpenAL and FMOD or anything like that.

I also don’t care about position of sound playing or anything because my game is in orthogonal mode. That’s why I’ve always just used Java’s built-in sound functions.

[EDIT]
Gosh… I’ve been all over the internet trying to figure out how to very simply play OGG files. If all else fails I’ll use WAV for now (I need this implemented for Tuesday). I looked in Slick’s source code, but there’s a rather obscene number of included classes (a number higher than I have in my entire game) that I would need just to play some sounds, so I’ve steered clear of that. I literally just want to play and loop WAV and OGG files. I don’t care about position, velocity, Doppler effect… But the internet seems to want me to be way complicated. I’m about to use Java’s methods for it.

FMOD has been removed in the latest LWJGL, so you probably don’t want to start using that. OpenAL is, frankly, a right pain to use. IIRC the recommendation was to switch to the Slick audio library if you just want basic sound playback.

The recommended alternative to FMod is not slick but slick-util, which is a part of normal slick.
It can be found at http://slick.cokeandcode.com/downloads/util/
with javadoc being at http://slick.cokeandcode.com/javadoc-util/

Haha, okay. Looks like I’ll be using Kevin Glass’s help yet again. I’m in the middle of trying to get Jorbis to work without OpenAL (holy crap what a pain… the file that uses the library is 2000 lines long. Why is that not a part of the library, don’t ask me).

In my opinion, a sound library should pretty much be like this:
Sounds.add(“name”,new Sound(“location”));
Sounds.play(“name”);

BAM!

I’ll take a look at Slick if I can’t get this JOrbis craziness to work.

[EDIT]
After spending another 45 minutes of my wading through an absolutely garbage tutorial on JOrbis (with plenty of archaic programming techniques, I might add), I discovered that, although promised, the tutorial never actually tells you how to play your file, even though you’ve spent 2000 lines of code learning how to get the API to create it. You end up with an InputStream. Hmmm… Anyway, deleted.

Off to Slick’s utilities! Rah!

or use http://www.cokeandcode.com/node/625

Haha. If only the world worked through Kevin Glass’s eyes, we’d all be happier people. Naturally, using his implementation worked almost immediately.

Cheers, and thanks for all the help, everyone.


Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:136)
	at org.newdawn.slick.openal.OggDecoder.getData(OggDecoder.java:322)
	at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:844)
	at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:813)

I can’t load an OGG file that is two and a half minutes long! Come on, now! Any way I can get around this?

you can increase your heap size, just add the vm arguement to what ever size you like, e.g

-Xmx512M

I wrote a an OGGInputStream and OGGPlayer that can be used to stream ogg files. http://home.halden.net/tombr/ogg/ogg.html

It was written a while ago aginst an older version of LWGJL, so some coding is probably needed to get it to compile.

I know I can do that, I was just hoping to avoid it. Is there any way to have Webstart do this automatically?

I also don’t know how to get Eclipse to do this.

Webstart:

Eclipse:

  1. Run > Run…
  2. Select the Run profile for your app/game
  3. Arguments Tab
  4. VM Arguments input box is where you put things like -Xmx512m

Or… if you’re happy to poll the music you could just stream it right from the file, meaning you don’t load everything into memory.

EDIT: Possibly the funniest thing I read in months:

Oh, how little you know! :slight_smile:

Kev

Great, thanks for the response. It’s very possible that polling the music would be fine, seeing as it only ever plays in one instance. How would I do this? I’m currently using your utils from Slick: SoundStore and Audio. I store loaded Audio files into a map and then play them from there.

Really, you shouldn’t be using this API through SlickUtil, but still. You can call:


SoundStore.get().getOggStream(string/url);

You’ll get a StreamSound back, and thats an AudioImpl which is an Audio. You need to remember to call


SoundStore.get().poll(delta);

In your game loop to give the streaming chance to take place. I would warn you that I don’t think any one has used Slick Util in that particular use case yet tho, so I guess we’ll work through it like normal :slight_smile:

Kev

Great, doesn’t look exceptionally difficult. I’ll give it a go later today.