Figure 10. Meme is a super-chimp, fighting his way past mad scientists and evil robots by hitting them with bananas. (Click image to play movie clip.)
One way to avoid the problems associated with background music is not to have any. Another Danger game, Meme, dispenses with music altogether, and uses mood-producing sounds instead. The "evil laboratory" level demonstrates the "pitch it up, play it down" technique to an extreme degree, and is used to solve a difficult problem: how do you create a low, creepy ambience using very little memory space? Traditionally, looping ambiences have to be fairly long (and therefore fairly large), otherwise you quickly hear the unnatural repetition of the same sound playing over and over. The other problem: How do you produce a Star Trek bridge-style rumble on a tiny cell phone speaker?
The answer, of course, is ... you don't. It's impossible. Here's what you do instead: Make a fairly high-pitched sound with a little blip in it and a little looped vibrato, like this:
Then make a custom RMF instrument out of it so you can play it at different pitches and layer it against itself. Then try playing it lower and lower until the sound starts to disappear, then bring it back up a little. That way, you get the lowest possible hum, the sound itself is very crunchy (which kinda works in this situation), and so it sounds something like Figure 10.
Man, that's a noisy game! You don't really miss the music much, do you? Other techniques demonstrated are the random pitching up and down of the banana whooshes, and prominent use of "vocal" sound effects (in this case, chimp noises) which punch through the tiny speaker loud and clear.
We also do the "single sample used in multiple ways" trick for the robot factories. Each time a robot is manufactured, there's this grating, grinding noise. It's the electrical-zap-played-down-an-octave machine:
Figure 11. Playing the zaps and pows at different pitches can produce interesting effects without using additional space. (Click image to play movie clip.)
During gameplay, the bottom end goes away because the speaker's too small to produce it, leaving only the higher-end grungy sound. Maybe it's not the sound effect you would have first designed for a robot factory, but it sorta kinda works and it doesn't use any extra space.
But my favorite use of that trick in this game is the cannon sound, which is the bullet played two octaves down:
This was totally unplanned; I was simply playing around with pitch-shifting and thought, "Cool, man, we got to use that!" Sometimes, happy accidents are your most valuable tool. Check out Figure 11.
I have a certain advantage in producing these kinds of interactive soundtracks because:
First, you'll have to see if your phone's operating system gives you access to the kind of APIs you'll need to implement things like pitch shifting and track muting. Some do, some don't. Then you'll need to check if the audio subsystem can even do what you want it to. If you're running Beatnik, you're probably golden; if not, well, good luck. The audio capabilities of cell phones and audio engines vary widely, from the completely rudimentary to the arcanely sophisticated.
To make good decisions about how to squeeze the maximum amount of sound out of the minimum amount of space, you'll want to design your audio taking into account the technical limitations of each platform your game is intended to run on. You'll need to know what file types are supported, at which resolutions, and what compression algorithms are available.
If you can run hi-res MP3s, you can pretty much make any sound you like, but if you're limited to, say, 8kHz IMA WAV files, you might want to consider using short, loud, uncomplicated sounds. These will translate better than complex noise, so forget that symphonic sample and use a single flute line instead. If the audio engine's output rate is 44k, rocking! Go for that screaming guitar solo, but if you're constrained to 11kHz, you're up against Nyquist, so you might be better off with a midrange piano solo. And no cell phone speaker is going to produce any bass whatsoever, so plan on using all tweet and no boom.
Most important, you'll need to know what your audio budget is—how much space is being allocated for sound. In most cases, if you want to make music, you're going to have to use General MIDI played on the internal wavetable, simply because it provides by far the most audio bang for your digital buck. But do yourself a favor and write for the basics—piano, horn, kick, snare, maybe some strings—and avoid things like the goblin pad, or the shakuhachi, and the other lesser-known patches. You have no idea how those instruments will sound on different devices and different soundbanks, whereas a piano is pretty much going to sound like a piano no matter where you go. In fact, solo piano music is usually a pretty safe bet in a General MIDI world, and I would suggest that being constrained to a single instrument didn't seem to hinder Bach's, Beethoven's, or Chopin's creativity.