Audio Compression using XACT
There are two pieces of feedback that I hear quite a bit related to the audio support in XNA Game Studio Express.
- It only supports WAV files. All of my sounds are in a different format, such as WMA.
- Audio binaries are too large. WAV isn't compressed, so my music tracks are huge!
We're investigating what we can do for the first issue, which would obviously help the second issue at the same time. But there is some support for compressing your audio files in the current product, using the XACT tool; it's just not easy to discover. XACT supports ADPCM compression on Windows and XMA compression on the Xbox 360. You can get about 4:1 compression with ADPCM and even better with XMA. So while perhaps not as high as some other encodings, such as WMA, it does offer quite a substantial savings.
So how do you enable compression for your Wavebanks? Let's take a look:
- Create an XACT project and a Wave Bank
Start the XACT editor by using the Start menu shortcut Microsoft XNA Game Studio Express -> Tools -> Microsoft Cross-Platform Audio Creation Tool (XACT). Create a new project and add a new Wave Bank to the project.
- Add some WAV files to the Wave Bank
While we won't be playing any sounds during this, we do want to see the results of the compression. Once your done with this, you should see something like the below screenshot.
- Create a new Compression Preset
You can create a group of compression settings via a Compression Preset. This allows you to reuse the settings across multiple Wave Banks. This is also why it's a bit hidden. Rather than adjusting the compression settings on the sounds themselves or the Wave Bank, we do it here. You can create a new Compression Preset easily by right-clicking on the Compression Presets item in the explorer.
- Tweak Settings
After you've created it, you can see the default compression settings for ADPCM and XMA. You do have the ability to change some of these settings, although we'll just leave the defaults for this exercise.
- Apply the Compression Preset to the Wave Bank.
This is as easy as selecting the Wave Bank we created earlier, and then selecting the Compression Preset we just created in the Properties window for the Wave Bank. This tells the XACT compiler that we would like it to compress the WAV files using the preset settings when it builds the Wave Bank binaries.
- Done!
If we look at the details for the WAV files that are in the Wave Bank, we see that they now indicate they are compressed and how much space is saved.
I hope this was helpful for those that didn't know about the ability to compress your audio binaries using XACT. While not as compressed as some other formats, it should provide for smaller game sizes, especially when including audio assets for background music.
Comments
- Anonymous
September 22, 2008
We've had some questions about what audio formats the XNA content pipeline can take as input, and what