Chapter 6. Sound Effects and Audio
All right, you have a solid design and you’re ready to move forward. At the end of the previous chapter, you ended up with something that actually resembles a game: you have a user-controlled sprite that can move around the screen, and once it comes in contact with one of the “enemy” sprites, the game ends. The main drawback is that the enemy sprites don’t move or do anything yet, so the game really isn’t all that great—but nonetheless, it’s a good start.
For now, let’s focus on another problem: there’s no audio in your game. What kind of game has no audio or sound effects? I’ll tell you: a lame game. We aren’t in the business of making idiotic applications—we’re XNA developers, and that means we’re going to make something awesome. So let’s do it. In this chapter, you’ll add some audio and sound effects to your application.
With the XNA Framework 4.0, there are a couple of different ways to implement sound. In previous versions of XNA, developers used a tool called the Microsoft Cross-Platform Audio Creation Tool (XACT) exclusively for audio. Using XACT, developers can create compilations of sound files that are processed by the content pipeline and implemented using the XNA Framework’s sound API. With XNA 3.0, the XNA team added a separate API for use in Microsoft Zune development. In XNA 4.0, both methods are still available. XACT is more robust and powerful but is available only in the HiDef game profile, whereas the simplified sound API is supported ...