This documentation is archived and is not being maintained.

Audio Overview

The XNA Framework provides audio playback through the Microsoft Cross-Platform Audio Creation Tool (XACT), and a simple SoundEffect class for audio playback that doesn't require XACT.

Audio Orientation

Some general terminology is provided below, followed by a more detailed discussion.


A wave is an audio data file used independently, or as a building block for creating game sound effects.

Wave Bank

A wave bank is multiple wave files logically grouped into a single file.

Sound Bank

A sound bank is a logically grouped collection of sounds (wave banks) and cues.


A cue allows a game programmer to play sounds. It is composed of one or more sounds, and is referenced through a sound bank.


Simple Audio Playback

The simplest way to play sounds for background music or sound effects is to use SoundEffect and SoundEffectInstance. Source audio files are added to the project like any other game assets. For example code, see How To: Play a Sound, How To: Loop a Sound, and How To: Change the Pitch or Volume of a Sound. For background music, see How To: Play a Song.

SoundEffect and SoundEffectInstance are available on Windows, the Xbox 360, and Zune. However, these APIs are the only audio option on Zune.

Introducing XACT

XACT is at the heart of the XNA Framework Audio API. XACT combines two things. It combines a powerful graphical tool for authoring audio content with an API that is responsible for interpreting the authored XACT files and playing audio in response to game events. It is expected that core audio elements (waves) will be fully developed before using XACT.

Getting Started with XACT

Not all features of XACT are necessary for a game title that uses simple audio playback. 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. To learn how to load and play cues from the XACT project you have built, see How To: Play a Sound Using XACT. To create simple sound effects without using XACT at all, 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

  1. Click the Start menu, and then click All Programs.

  2. 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 about categories, variables, and other advanced features, see XACT Audio Authoring.

Programming for XACT

Once you create an XACT project and save it as an .xap file, add the .xap file and any wave files the XACT project uses as input to your XNA Game Studio game. 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 load the necessary files, you can access cues created by the audio designer 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 you retrieve 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 the Play, Pause, Resume, and Stop methods, respectively. See How To: Play a Sound Using XACT for information about how to play a cue. For more information about how to pause, resume, and stop cues, see How To: Stop or Pause a Sound Using XACT.

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 Using XACT.

3D Audio

Both the Cue and SoundEffect classes provide the ability to place audio in a 3D space. By creating an AudioEmitter and AudioListener object, both sound playback APIs can position a sound in 3D, and change the 3D position of a sound during playback. Once you create and initialize the AudioEmitter and AudioListener, call Cue.Apply3D or SoundEffectInstance.Apply3D.