Cheese Racer is a game, based on Rally X, that uses a number of techniques to produce lots of sound and music in very little space, including:
Figure 2. This MIDI sequence contains all of the tracks used for the Cheese Racer game. It plays instruments from the built-in General MIDI soundbank, along with custom samples contained in an RMF file. (Click to enlarge.)
Let's look at the music soundtrack first. Figure 2 is a screen shot of the MIDI sequence used in the game, displaying the complete track layout. Since this game was designed to run on the Hiptop, which uses the Beatnik Audio Engine as part of the OS, we were able to use an RMF file to create the soundtrack. This means that during gameplay, the MIDI sequence pictured here is rendered on instruments from the internal General MIDI soundbank, and on custom software instruments specifically designed for the game.
For example, the top two tracks play custom samples of drum loops:
Next we have a group of three tracks, playing bass, melody, and chords:
In the code for the first level, we've defined ten different combinations of tracks: percussion + bass, percussion + bass + melody, bass + melody + chords, etc. You can hear what it sounds like by clicking the movie clip in Figure 3.
Figure 4. Every time you play the game, the soundtrack is different. (Click image to play movie clip.)
Figure 3. Notice how the mix changes every time the mouse gets a piece of cheese. (Click image to play movie clip.)
Because the music loop is 40 seconds long and we defined ten different combinations of tracks, each level contains more than six minutes of different music mixes. Of course, not every mix is played for 40 seconds—in fact, that's kind of the point. Because the mix changes depending on gameplay, the music will never play exactly the same way twice, thereby increasing variation and decreasing "ear fatigue."
But wait! There's more! In fact, there are two more sets of tracks playing two more styles of music, using the same tempo and percussion tracks as the first level. Therefore the entire game contains almost 20 minutes of various music mixes, using only 68K of compressed sample and MIDI data. Click on Figure 4 to hear a different performance. This time, notice the use of "bumpers" to smooth out transitions between mixes, and when moving to the next level. (Special thanks to Lucas Finklestein, Danger QA engineer and game player extraordinaire, for helping me film these sequences.)
Remember, you want as much variation as possible, and you really want to avoid hearing the same sound over and over again. This game contains only a single "trumpet fall" sound effect, but we modify the playback sample rate so that each time you pick up a piece of cheese, the sound is played at a different pitch ... any similarity to the 1960s Batman theme is entirely intentional:
We also randomly vary the pitch during gameplay, so there's no repeating pattern to it:
Figure 5. By randomly varying the pitch of the car horn beeps, we produced multiple sounds using only one file. (Click image to play movie clip.)
The sound tends to mask the transition from one mix to another, helping to create a more seamless audio experience. In Figure 5, you can hear the same kind of pitch-shifting effect applied to car horn beeps.
Another way to save space is using the "pitch it up, play it down" technique. Here's how it works: take your original, high-resolution sound effect and transpose it up an octave, halving the length. Then convert it to a low-resolution compressed format, like this:
Then in the game, play it down an octave:
Although the game sound might be a little crunchy, you've just cut the size of your file in half without losing too much audio fidelity. Obviously, the higher you pitch the sound, the "crunchier" the playback will become, but the technique can be used for custom instruments as well as sound effects, and is particularly effective on the tiny speakers in mobile devices.