Which Java sound API is the best?

Hi!

I’m integrating sound/music in MightyBubbles (http://www.myjavaserver.com/~theanalogkid/servlets/app/mighty_bubbles.jnlp) but I don’t know which Java API whould be the best for that?

Is Jorbis a good choice?

Thanks for answers!

Jorbis is “just” a ogg decoder lib. It’s unable to playback those decoded pcm bytes.

The involved overhead is about 80kb… so if you got more than a handfull of samples (low quality 8bit/mono/11khz) it might be worth it.

For actual playback you would either use java’s (newer) sound stuff, lwjgl’s sound stuff (openal), fmod (through lwjgl) or joal.

I tought someone said that Java Sound sucks concerning performance?

Is that true that ogg files are smaller that mp3 files for the same bit rate? Apart playback performance, my other concern is about file size.

Thanks!

JavaSound had very high-latency sound, the kind that was unacceptable (IMO) for an arcade game. Everything was done in software on Windows prior to Tiger.

Now that the new DirectAudioDevices are returned by the mixers, you can have the same kind of performance (latency-wise) as you would thru DirectSound.

HOWEVER, the JavaSound specs do NOT impose that an implementation support basic controls such as volume changes. Apparently the goal was to provide just a “pure” line to the sound card, nothing more.

What this means is if you want anything more than straight playback and looping, you have to implement your own DSP functions. Yes, even for stupid volume changes, just in case the implementation you’re using doesn’t support the control. It most likely won’t unless you’re using JS’s non-hardware mixer, the default prior to DirectAudioDevices.

Tritonus.org has some JS-plugins that do the heavy-lifting (especially for volume changes), but you still have to integrate it to your mixing routines. Definitely not a plug-and-play solution.

I implemented by game audio lib a couple of months ago, after looking at the open source alternatives and their deployment/stability issues, I chose JavaSound and I’m still happy with it. I spent a lot of time tho tweaking my mixing routines to avoid any pops/clicks during my sound playback. Beware. I also only play wave files in my game.

I recommend you give a hard look at all other alternatives first.

HTH,
BK

Thanks a lot for the very useful hints!

I recommend LWJGL’s OpenAL and FMOD support. It’s teh b0mb. Really! I use Jorbis with OpenAL and I’ve got tons of music in my game and sound effects playing. Great stuff.

Cas :slight_smile:

[quote][…]
Is that true that ogg files are smaller that mp3 files for the same bit rate? Apart playback performance, my other concern is about file size.[…]
[/quote]
What’s heavier one kg feathers or one kg lead? :wink:

With the same bitrate both files would be about the same size (xxx bytes per second +/- some bytes for the header).

The benefits of ogg are better sound (especially at low bitrates) and it’s royality free (whereas mp3 isn’t).

[quote]I recommend LWJGL’s OpenAL and FMOD support. It’s teh b0mb. Really! I use Jorbis with OpenAL and I’ve got tons of music in my game and sound effects playing. Great stuff.

Cas :slight_smile:
[/quote]
ok thanks!

and where do you get those tons of sounds?

I paid for them :slight_smile: Mike Huang did the sounds for about $15 a pop. See http://www.michaelhuang.com.

I’m really glad I did get him to do them - I can easily spend an entire day on one sound effect and still not get anything I like. He just did the lot in over 2 weeks over about 3-4 iterations.

Cas :slight_smile: