The Microsoft Cross-Platform Audio Tool, or XACT, is at the heart of the XNA Framework Audio API. XACT is a combination of a powerful graphical tool for authoring audio content, and an API that is responsible for interpreting the authored XACT files and playing audio in response to game events.
Getting Started Quickly
Not all features of XACT are necessary for a game title that uses simple audio playback. However, the XNA Framework interprets audio only from XACT files, so even games with simple audio must use XACT. To learn how to create a simple XACT project that contains only a few wave files, see How To: Add a Sound File to Your Game Using XACT. Then, to learn how to load and play cues from the XACT project you have built, see How To: Play a Sound.
What XACT Does
As a GUI-driven audio content creation system, XACT enables audio designers to load wave files into groups, organize the files into discrete "cues" that can be activated by in-game events, and create transitions between cues. XACT also enables designers to define variables that can be changed in-game to modify audio settings. With these advanced tools, an audio designer might, for example, design a set of car engine sounds for a racing game, and through the use of a variable, cause the car engine sounds to increase or decrease in pitch and volume as the variable is controlled in-game by the XACT engine.
To get started using XACT, click the Start menu, and then click All Programs. Click the XNA Game Studio folder, then Tools, and then click Microsoft Cross-Platform Audio Creation Tool (XACT).
For detailed information about how to author audio in the XACT tool, including information on categories, variables, and other advanced features, see XACT Audio Authoring.
Programming for XACT
Once you have created an XACT project and saved it to a file as an .xap file, add the .xap file and any wave files the XACT project uses as input to your XNA Game Studio game, and the Content Pipeline will build the needed files for you to access your content at run time.
An XACT project builds a set of files: a global settings file (.xgs), one or more wave banks (.xwb), and one or more sound banks (.xsb). These files may be provided to AudioEngine, WaveBank, and SoundBank constructors, respectively.
To initialize the XACT engine, you must create a new AudioEngine and provide the path to the global settings file. Then, load any wave banks you need by creating new WaveBank objects, and load any sound banks that you need by creating SoundBank objects. Once you have loaded the necessary files, you can access cues that the audio designer has created by calling GetCue on the SoundBank that contains the Cue that you want to retrieve. Each Cue instance that you retrieve is unique, even when retrieving multiple cues with the same name. This allows multiple instances of the same Cue to exist and play simultaneously.
You can play, pause, resume, and stop Cue objects by using, respectively, the Play, Pause, Resume, and Stop methods. See How To: Play a Sound for information about how to play a cue, and How To: Stop or Pause a Sound for more information about how to pause, resume, and stop cues.
Periodically, you must call Update to allow the audio engine to process audio data.
For more advanced projects, you can also access AudioCategory objects for controlling the playback of sound categories by calling AudioEngine.GetCategory. Also, to access variables that the audio designer has tied to playback changes in volume, pitch, or DSP effects, you can call AudioEngine.GetGlobalVariable. For more information about how to use categories to change sound volume levels, see How To: Change Sound Volume Levels.