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.