Chapter 6. Playing Sounds and Music

We hear sound effects and music in almost every type of media we encounter daily. Many notable games such as Pac-Man, Angry Birds, and Fruit Ninja can be recognized just by their theme music or sound effects alone. Aside from the visual imagery we see in games, sounds help impact the mood conveyed in the storyline and/or during game play. Quality sound effects and music that pertain to the theme of your game helps give a realistic feel to the experience.

In this chapter, you will learn how to apply sound effects and music that can be added to your applications. You have the visual appeal down from creating Breakout and Panda Star Catcher in the previous chapters. Now, let's enhance the sensory experience for our ears!

The main points you'll be going over are:

Let's create some more magic!

The Corona audio system has advanced Open Audio Library (OpenAL) features. OpenAL is designed for the efficient rendering of multichannel three-dimensional positional audio. The general functionality of OpenAL is encoded in source objects, audio buffers, and a single listener. A source object contains a pointer to a buffer, the velocity, position and direction of the sound, and the intensity of the sound. Buffers contain audio data in the PCM format, either 8- or 16-bit, in either mono or stereo format. The listener object contains the velocity, position and direction of the listener, and the general gain applied to all sounds.