Summary
In this chapter, you learned the sound effects in xNa. Whether you like it or not, you must use xact. Xact enables you to play sound effects and music on the Xbox 360 and Windows platforms.
The following are the key points you have learned in this chapter:
Xact is the only way to use xNa to play a sound on Xbox 360.
The xact tool may be annoying at first, but once you get used to it, you can enjoy new and cool features. For exampleCodeTo enable fade-in and fade-out, it is easier to set in xact.
Xact does not support MP3, Ogg, ACC, and other custom compression formats. Only two formats are supported: ADPCM on Windows and xma on Xbox 360.
- Xma is a good compression format for Xbox 360, but ADPCM is not really useful. If you have time and want to use smaller audio files on Windows, you can implement directaudiovideoplayback to your engine or use other external sound engines from the DirectX SDK.
I recommend 75% quality for xma, and ADPCM recommends 128 or 256 samples for each block. The Windows version may be twice the version 360 because the ADPCM encoding compression rate is poor.
Makes the sound class easy to use and can be used anywhere.
Use sound enumeration to quickly obtain and play available sound cue.
Compile helper classes for your frequently called code.
- In xact, the custom cue variable is first set and then imported to xNa code. The setvariable method can modify the cue instance variables.
The next chapter discusses the input class keyboard, mouse, and Xbox 360 handle, which is already in the graphics engine, but all the methods are not discussed in detail. In addition, you will understand the menu system and user interface code. For example, the user interface code automatically plays a sound every time you move or click the control. For custom controls, you must perform all inspection and processing on your own. You can also learn about xNa shooter games, which will be completed in Chapter 11th.