Skip to Main Content
Learning XNA 3.0
book

Learning XNA 3.0

by Aaron Reed
November 2008
Beginner content levelBeginner
510 pages
16h 24m
English
O'Reilly Media, Inc.
Content preview from Learning XNA 3.0

Using the Simplified API for Sound and Audio

When developing for the Xbox 360 and the PC, it's a good idea to take advantage of the benefits that XACT offers. However, XACT isn't supported on the Zune, so the XNA Framework 3.0 provides a simplified sound API that's been added to allow developers to play audio on the Zune. You can also use the simplified API in projects for the Xbox 360 and the PC, if you find that you don't require the additional features provided by XACT.

Close your current XNA game project and create a new XNA Windows Game project in Visual Studio called SimpleSounds.

To play a sound using the simplified sound API, the first step is to add a sound file to your project. Remember that when dealing with XACT, the actual sound files themselves are not added to the project in Visual Studio. That is not the case, however, when dealing with the simplified sound API. In this case, audio files are treated like other resources in the content pipeline and have to be added to the Visual Studio project just as you've done with your 2D images thus far in this book.

The sound API in XNA 3.0 supports the .wav, .wma, and .mp3 file types. In this example, you'll be using the start.wav file used in the previous example in this chapter. You should already have this file on your hard drive, but if not, you'll find it with the Chapter 5 source code in the SimpleSounds\Content\Audio folder.

Add a new content folder to your project by right-clicking the Content node in Solution Explorer ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning XNA 4.0

Learning XNA 4.0

Aaron Reed
Beginning C# 7 Programming with Visual Studio 2017

Beginning C# 7 Programming with Visual Studio 2017

Benjamin Perkins, Jacob Vibe Hammer, Jon D. Reid

Publisher Resources

ISBN: 9780596154905Supplemental ContentErrata Page