Export (0) Print
Expand All

Getting Started with XACT

XNA Game Studio 4.0

The XNA Framework provides audio playback through the Microsoft Cross-Platform Audio Creation Tool (XACT), and a simple SoundEffect class for audio playback that does not require XACT. XACT is supported for Windows and Xbox 360 platforms and not Windows Phone.

Introducing XACT

XACT, the heart of the XNA Framework Audio API, 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 for playing audio in response to game events. It is expected that core audio elements (waves) are fully developed before XACT is used.

Getting Started with XACT

Not all features of XACT are necessary for a game title that uses simple audio playback.

XACT Audio Terminology

XACT uses the following terminology for the organization of sound files:

Wave

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

Wave bank

A wave bank contains multiple wave files that are logically-grouped into a single file.

Sound bank

A sound bank is a logically-grouped collection of wave banks and cues.

Cue

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

Ff827592.PG_Audio_AudioOverview(en-us,XNAGameStudio.40).png

What XACT Does

As a audio content creation system driven by a graphical user interface, XACT enables audio designers to load wave files into groups, to organize the files into discrete cues that can be activated by in-game events, and to 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 Start, and then click All Programs.

  2. Click the XNA Game Studio folder, select 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 builds the needed files for you to access your content at run time.

An XACT project builds a set of files: a global settings (.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

  1. Create a new AudioEngine, and provide the path to the global settings file.

  2. Create new WaveBank objects to load any wave banks you need.

  3. Create SoundBank objects to add any needed sound banks.

Ff827592.note(en-us,XNAGameStudio.40).gifNote

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 Playing Sounds from an XACT Project for information about how to play a cue. For more information about how to pause, resume, and stop cues, see Pausing a Sound (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 to control 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 Adjusting Volume (XACT).

Community Additions

ADD
Show:
© 2014 Microsoft