Sound Effects and Music


  • Sound Basics
  • The Java Sound API
  • Playing a Sound
  • Creating a Real-Time Sound Filter Architecture
  • Creating a Real-Time Echo Filter
  • Emulating 3D Sound
  • Creating a Sound Manager
  • Playing Music
  • Summary

Unless you've never managed to figure out how to hook up speakers to your computer, you've noticed that games have sound effects—cool sound effects—and sometimes music, too. When you're playing a game (with the speakers on, of course), you might hear the sound effects but not really notice them. That's because you expect to hear them—sometimes sound effects are something you notice only when they're missing. They're sort of like electricity. To sum it up, sound effects are an important part of a game. People expect to hear them, and they shouldn't be left out. In this chapter, you'll learn the basics of playing sound and then move on to real-time sound-effect filters (such as echoes). You'll also create a sound manager to handle it all. In addition, you'll learn to play music (such as CD audio, MP3, Ogg Vorbis, and MIDI) and to make the music dynamically change to adapt to the state of the game.