Professional Documents
Culture Documents
Playing Sounds From An XACT Project: Complete Sample
Playing Sounds From An XACT Project: Complete Sample
This section demonstrates how to initialize the audio engine, to load sound banks and wave banks created using XACT, and then to play a sound by using a Cue object.
Complete Sample
The code in this topic shows you the techniques for initializing, loading, and playing sounds. You can download a complete code sample for this topic, including full source code and any
additional supporting files required by the sample.
Download PlaySound_Sample.zip
C#
// Audio objects
AudioEngine engine;
SoundBank soundBank;
WaveBank waveBank;
2. Initialize the audio objects by loading the XACT sound files, and then use a Cue object to play the sound.
C#
Each Cue instance that you play is unique, even when you play multiple cues with the same name. This enables you to play multiple instances of the same Cue simultaneously.
Concepts
Adding a Sound File (XACT)
Demonstrates how to add wave (.wav) files to an XACT project that can be built and interpreted by an XNA Game Studio game to play audio.
Pausing a Sound (XACT)
Demonstrates how to initialize the audio engine; how to load a sound bank and wave bank; and how to play, pause, resume, and stop a sound (called a cue).
Playing a Sound
Demonstrates how to play a simple sound by using SoundEffect.
Reference
AudioEngine Class
Represents the audio engine. Applications use the methods of the audio engine to instantiate and manipulate core audio objects.
Cue Class
Defines methods for managing the playback of sounds.
SoundBank Class
Represents a sound bank, which is a collection of cues.
WaveBank Class
Represents a wave bank, which is a collection of wave files.
Community Additions
© 2014 Microsoft
http://msdn.microsoft.com/en-us/library/dd231915(d=printer).aspx 07/11/2014