Music playback

A soundtrack in a demo is a must.

I’m currently prototyping miscellaneous stuff and just did my first audio playback test with the XNA. Standard wave files can be played on both win32 and XBOX360 environments. Uncompressed wave files tend to be huge and luckily it is possible to compress the sounds. On win32 the only option is ADPCM and for the XBOX there is XMA. It would be nice if MP3 or OGG were supported..The tune I tested for compression was originally a variable bit rate MP3 10MB in size. Uncompressing it into wave produced a 54MB file. Again compressing the wave file using the XACT tool with default compression settings (128 samples per block for ADPCM and quality level 60 for XMA) resulted in a 15MB file with ADPCM and a 7MB file with XMA compression. With quality value of 100 the XMA compressed file was 20MB in size. I didn’t do any proper listening tests yet so I don’t know what the worst quality sounds like.

The XACT tool may be confusing at the first glance but there is a good example in the documentation. However there is no compression used in the example. It is pretty straightforward to do: add a new compression preset, adjust the quality settings if needed and finally set the wave bank to use the new compression preset.

The actual playback is a very simple thing to do. Just load the sound and wave bank files and play the cue. Again, there is a good example in the documentation. It took less than 10 minutes to configure and compress the wave file and to make it play in the XNA application.

There is one important feature missing from the XNA. There is no way to know at what position is the sound clip currently playing. This information is crucial when the demo uses the music to sync all the effects (not the actual sound data but the playing time). One solution is to start a timer at the same time with the music and hope it won’t go out of sync. I have to test this later.

– fragment

Leave a Reply

You must be logged in to post a comment.