Blog'A'Little

Just another C# guy

Compressing audio in Xna for Windows

Xna does not support MP3 or WMA, neither on Xbox or Windows. For Xbox you have a format called XMA that is pretty much like WMA on Windows, but for Xna for Windows you have to resort to uncompressed (PCM) or close to uncompressed (ADPCM). This tutorial shows you how you can use ADPCM and get at least some compression for your sounds and save a bit of space. The average compression rate is 27% for the default settings.

We will be using XACT (Microsoft Cross-Platform Audio Creation Tool) that comes with both Xna 1.0 and 2.0.

Create a new project by going to File->New Project (Ctrl +N) and create yourself an empty project.

image

You then get a screen looking something like this:

image

First we will create a compression preset by right-clicking the compression presets and select new compression preset:

image

Give it a name, so you'll recognize it later on in the process.

Now we need to select ADPCM and samples per block:

image

We'll leave the samples per block to 128, which is default. The quality of the sound is quite good with this setting.

Now we need to create a wave bank by right-clicking the wave banks in the project and choose new wave bank:

image

Leave the default settings for now.

You're then given a window where all your wave files will exist for that particular wave bank. Here we can insert our wave files.
Just right-click inside the window and choose to insert wave files:

image

Select your wave file:

image

We can now select the compression preset we want to use for the imported wave by selecting the wave file and then selecting the correct preset in the properties in the lower left of the application:

image

Now we need to create sound bank by right-clicking the sound banks and choose new sound bank:

image

Open your wave bank and select the wave file you want to be cue in the sound and drag it from the wave bank onto the cue part of the window.
The result should be something like this:

image

You now have a project you can build and use from your solution programmatically.

kick it on DotNetKicks.com kick it on GameDevKicks.com

Comments

GameDevKicks.com said:

You've been kicked (a good thing) - Trackback from GameDevKicks.com

kick it on DotNetKicks.com kick it on GameDevKicks.com
# april 2, 2008 11:20

grand-gambler.com said:

good story, all laid out on the shelves

kick it on DotNetKicks.com kick it on GameDevKicks.com
# april 1, 2010 3:52

panasonic wireless cameras said:

Immense early areas grow communications in side of materials and are often a dynamism of magnetic speeds.

kick it on DotNetKicks.com kick it on GameDevKicks.com
# mai 19, 2010 7:34

payday loans online said:

Your website is very interesting. I enjoyed your website a lot. Thank you.

kick it on DotNetKicks.com kick it on GameDevKicks.com
# juli 2, 2010 7:17

payday loans said:

Your weblogblog site is excellent. Give thanks to you very much for sharing a great deal of valuable critical information. Most definitely i'll bookmark your website and will be definitely coming back. Once again, I admire your work and also sharing such an abundance of vital related information to the readers.

kick it on DotNetKicks.com kick it on GameDevKicks.com
# august 25, 2010 3:42

loans british columbia said:

uqpaurcycvxghghtaeiknthsmtzdldgqwil

kick it on DotNetKicks.com kick it on GameDevKicks.com
# september 2, 2010 3:24
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Design downloaded from Free Templates - your source for free web templates