Slick-Util Library - Part 2 - Loading Sounds for LWJGL

As Java has built in support for the WAV and AIF format Slick-Util can load these sound formats out of the box. Additionally Slick-Util supports the OGG and XM formats using external libraries. Sound formats can either be completely loaded into memory or streamed from the file.

OGG Support

OGG is a patent free format and comparable to MP3 in features. Slick-Util supports this through the use of the Vorbis library. So if you intend to use OGG files you must also add the jorbis-*.jar and jogg-*.jar library jar files to the classpath, these can be found in the Slick-Util zip download.

XM Format

The XM format is a tracker format and is supported in Slick-Util with the support of the IBXM library. So if your using this format you will also need to add the ibxm.jar library jar to the classpath, it can also be found in the Slick-Util zip download.

Basics

Loading sounds with Slick-Util is pretty easy and similar to how textures are loaded. All the sound files are stored in the Audio class and loaded into that class using the AudioLoader class.

Since you are using OpenAL, do not forget to call the AL.destroy() method before your application closes. This will clean up the sound resources you are using.