Chapter 9: Adding Sound with XACT


Overview

This chapter takes a closer look at XACT. XACT is the name for Microsoft’s Cross-Platform Audio Creation Tool, which allows you to create audio projects for the Windows and Xbox 360 platforms. It is actually the only way to play sounds in XNA. That doesn’t matter so much for the Windows platform because you can plug in any other sound engine you want (DirectSound of DirectX, OpenAL, FMod, and so on) and play sound or music this way. It is not that easy on the Xbox 360 because you can only use the XNA Framework here and it is absolutely not possible to use any other framework for playing sound. The reason you can’t use anything but XACT is the fact that you cannot use any unmanaged code in XNA, and to play sound or use any low-level hardware on the Xbox 360 you would need unmanaged code to access it. For the same reason you cannot use any other graphics or input engine than the one XNA provides for you.

But XACT isn’t all bad; the reason why it was implemented into XNA is to make sure it is possible to use the same sound content and sound playback code for both the Windows and the Xbox 360 platforms. For example, the Xbox 360 supports only XMA compression; the PC uses other compression formats for sound and music like MP3, OGG, ADPCM, and many other custom compression formats, but only ADPCM is supported in XACT. Voice over IP applications often use their own proprietary sound compression format because the human voice can be compressed better than music, for example. Sound effects are very short and small anyway, but you as a game developer usually want the highest possible quality for sound effects and therefore sound effects are often uncompressed or use lossless compressions. Music, on the other hand, takes up a lot of space. If your game is on a DVD or you have plenty of hard disk space you can waste, you could just store the music as uncompressed wav files or directly on the CD or DVD. For XNA games this is not an option because you can’t access the DVD on the Xbox 360, and wasting a few hundred MB for just the music is not a good idea for your game.

In the past with DirectX or Managed DirectX applications you would most likely use DirectSound for the sound playback or use other frameworks like OpenAL or commercial sound engines like FMod. Even with these frameworks you will still have to do a lot of custom code; you have to decide which sound format is the best for you and you will have to worry about sound compression yourself. Additionally, you must implement a way to play music yourself too. For example, DirectSound is really not usable for music - it just supports .wav files - but if you want to play MP3 or OGG music files, you have to use other frameworks like DirectShow, Windows MCI, ActiveX sound playback codecs or other free and commercial frameworks and sound engines. Yes, you are right, this sounds like a lot of work. The actual code to play back sounds or music is very simple for most games. It gets a little bit more complicated if you want to use complex 3D sound calculations and if you want to support surround sound, but it is still way easier to program these things than to develop your 3D engine.




Professional XNA Game Programming
Professional XNA Programming: Building Games for Xbox 360 and Windows with XNA Game Studio 2.0
ISBN: 0470261285
EAN: 2147483647
Year: 2007
Pages: 138

Similar book on Amazon
XNA Game Studio 4.0 Programming: Developing for Windows Phone 7 and Xbox 360 (Developer's Library)
XNA Game Studio 4.0 Programming: Developing for Windows Phone 7 and Xbox 360 (Developer's Library)
Learning XNA 3.0: XNA 3.0 Game Development for the PC, Xbox 360, and Zune
Learning XNA 3.0: XNA 3.0 Game Development for the PC, Xbox 360, and Zune
Beginning XNA 2.0 Game Programming: From Novice to Professional (Expert's Voice in Game Programming)
Beginning XNA 2.0 Game Programming: From Novice to Professional (Expert's Voice in Game Programming)
Microsoftu00ae XNAu00ae Game Studio 3.0: Learn Programming Now! (Pro - Developer)
Microsoftu00ae XNAu00ae Game Studio 3.0: Learn Programming Now! (Pro - Developer)

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net