Playing Music

I’m planning to put music into a game I’ve been working on in the next few days, and well… I wanted to know what people here recommend. I’d like to have a reasonable level of quality for the music, but I haven’t ruled out midi just yet either. Most likely whatever I go with will be about a 30 second loop that’ll probably fade in or out whenever the music begins/stops/changes.

So here are some of the things I’m not sure about…

What format to save the music files in (assuming I didn’t go with a midi approach)? A wav file would probably be simple but that seems kind of like using an uncompressed bmp image these days, my game would most likely be distributed via webstart so size is an issue.

Is speed likely to be a problem? I already loop a few sounds in my game but those are very short clips, and I suspect that something larger is going to either require a lot more time due to the amount of memory used or based on it not being loaded into memory at all and streamed in due to size.

Soundbanks for windows… is this something an end user would potentially have to deal with, or has it become part of the core distribution since sometime after 1.3?

I appreciate any feedback on these questions, sound isn’t something I’ve messed with much, and short of moving my music off of CD into mp3’s on my computer my file format know how is pretty much nothing (wavs are accurate but massive, and mp3 are small but I imagine playback in java wouldn’t be ideal especially with everything else my game is already doing but if I’m wrong please correct me on that point).

Wave files, isn’t really an option due to size issues. However you may be able to use ogg vorbis, and then decompress those to wav files at runtime (or installation time). There is a vorbis library for java (http://www.jcraft.com/jorbis/).
You could play the wave file as you would normally.
You could also use the FMOD binding in LWJGL, and use this to play modules, midi or ogg vorbis / mp3 (http://puppygames.net/forums/viewtopic.php?t=573)

Soundbanks for windows… is this something an end user
would potentially have to deal with, or has it become part of
the core distribution since sometime after 1.3?

The JRE comes without a soundbank.

http://java.sun.com/products/java-media/sound/soundbanks.html

Without a soundbank midi and rmf will sound like… erm… poo. :-/

mp3

MP3 isn’t really an option. The license fees are pretty high and… well there is OGG. It’s free and sounds much nicer - especially with low bitrates. (The Jorbis lib does all those tricky things for you.)

Basically there are two ways then. Either pre-decode into pcm (eg for sound effects) or streaming (decoding of tiny chunks just in time - eg for music). Playback of pre decoded oggs is of course pretty fast (just as wavs), but it needs some ram. Streaming needs more cpu power, but much less ram. However, the usage isn’t that high… about 5-10% on a 500mhz machine.

Oh and there is also MOD (a tracker format) you can either playback it with the MicroMod lib or over the fmod lwjgl binding (fmod plays about every audio format).

jorbis looks pretty promising. I’m trying to keep as few native dependencies in my game as possible so I don’t think fmod would be suitable, though I’ll have to look at everything in LWJGL a bit closer for my future games.