Game Development Community

Compressed music in Java

by Steve Fletcher · in Technical Issues · 09/13/2003 (12:45 pm) · 3 replies

I have a Java game that is basically done except that it is waiting for some art.

The problem is that the music is too big when stored as uncompressed .wav files, but that's the best that Java can do easily.

I need something smaller.

I've tried using some free libraries for Ogg Vorbis, but I haven't been able to get them to work yet (well, the example program for one of them works, but I can't get it to work in the game). I thought I had gotten it to work, but the next time I turned the computer on, the program wasn't working.

I have been to http://www.jsresources.org/examples/jse_audio.html as well as several Ogg Vorbis sites, but none of them solved my problem.

I suspect that it would be better to post on an Ogg Vorbis forum, but I figured I'd post here first. After all, I'm already here to check GG's forums.

A couple facts I should mention:

I can get .wav files to load fine.

The game in question is a full-screen application, not an applet.

I was using Java 1.4.0. I also have Java 1.4.2 on a different computer, but it should work with 1.4.0 as well.

#1
09/13/2003 (8:43 pm)
Java can play lots of different file formats, wav is just one of them. See the Java Media API docs on the sun site.
#2
09/14/2003 (7:15 pm)
Yes, I know.

But most of the music file formats that Java can load without you having to do any extra work are uncompressed and roughly equal in size to .wav files.

The only other format Java supports without alot of work is MIDI, and that's just not good enough. I don't have MIDI music; I have mp3's. They don't use MIDI's instruments.

My question was HOW to use compressed music file formats. In particular, I'm interested in Ogg Vorbis.

I've tried using free Ogg Vorbis libraries, and I can't get them to work. The problem is that it takes hundreds of lines of code that I don't understand to use the library - at least for the only library I found that I had an example.

I have read Sun's information on the Java Sound API and the Java Media docs. I have also looked at various non-Sun tutorials. I cannot understand how to load compressed music.

What I'm hoping for is a link to either a free library that I can actually get to work or a link to a tutorial that I can understand.
#3
10/15/2003 (7:51 am)
All right, I got jorbis to work. It's freely available from http://www.jcraft.com/jorbis/ .

Their example program is very confusing, but I eventually figure out how to make it work. I just removed the code that had nothing to do with music one piece at a time. Then I looked at what was left.