Tutorials

Compressing audio in Xna for Windows

NivÄ : 100

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.

Comments

 

digitalerr0r said:

Thanks for this :)

april 17, 2008 11:12

About Einar Ingebrigtsen

I've been doing software development since forever.. :) Started off with a Commodore 64 attached to my fingers for several years, went on to Amiga, Atari and later the PC. I was involved in the demoscene on all of the above mentioned platforms under the nickname Adept in several different groups; Legion Design, Scoop, Melon Dezign to mention but a few. Started doing professional software development in 1994 for FunCom with the prime responsibility of doing the 3D rendering engie for a PC/DOS game called Deadly Skies. Went on to doing the game engine for Windows/DirectX and Playstation for Dragonheart. Did some SNES coding in between. In 1996 a bunch of us quit FunCom and started our own company called Dimaga Studios. We went on making games for Windows/DirectX, Playstation and SEGA Saturn. The company fusioned in 1997 with Innerloop and the new name was Innerloop Studios. I quit the company later that year and started doing interactive TV solutions for a company called Playbox. Carried on doing interactive TV games and services till 2002 for Playbox and later Hermes Interactive. In 2002 I went on doing something completely different; enterprise level business applications. After working with Visual Studio .net BETA in 2001, and looking at the .net framework and C# we started the process in 2002 on moving the code over to this platform. 6 years later I'm still in the same company (still moving the code to C# :) ). Every now and then I found myself missing doing games fulltime. Early 2007 I got an email from Rune Grothaug at Microsoft Norway (DPE Team - MSDN) with a link to DevelopMentals Canadian Game Camp site. 24 hours later the GameCamp.no domain was purchased and CommunityServer installed on my server. Now I get to feed my game development nerve every now and then; through working the community by creating tutorials, newsposts, forum discussions and holding Game Camp events.