Playing Background Music (XACT)

XNA Game Studio 4.0

Demonstrates how to specify sound (.wav) files as background music. Specifying background music enables the XNA Framework to override the background music with the user's music choice, without interrupting other game sounds such as sound effects. This is accomplished by setting the sound bank category to music in the Microsoft Cross-Platform Audio Creation Tool (XACT).

Streaming allows for a .wav file to be read gradually from the disk rather than loaded into memory all at once. Because background music files may be larger than other files containing game sounds, they typically are streamed. In XACT, you need to create and use a streaming WaveBank to stream background music. To learn about streaming, see Streaming a Sound (XACT).

Specifying Background Music in Your Game

This procedure assumes you have already created an XACT project.

To specify background music in your game

  1. On the File menu, click Open Project.

  2. Browse to your project location, and click Open to load it.

  3. Double-click the sound bank that contains the background music.

    This highlights the sound bank in the left navigation tree, and displays the sound bank properties pane.

  4. Click the sound you wish to designate as background music.

    This displays the properties pane, and then shows the category options for the sound.

  5. In the Category box, select music, and then save the project.



Community Additions