APPENDIX A: Audio Concepts, Terminology, and Codecs 659
Synthesizers take digital audio—whether it’s a generated wave borne out of an oscillator on a circuit
board in a consumer electronics device, or a more complex sampled waveform, such as a sample of
a plucked instrument string—and apply algorithmic processing to the waveform to create a different
tonality, sound, or special effect. We’re all familiar with the synthesized instruments in popular music
today; these virtual instruments are created solely by using math and programming code!
One of the foundational mathematical manipulations that can be applied to audio waveforms within
the digital audio domain is called pitch-shifting. This was the core technology that made keyboard
samplers viable, as one sample could be used up and down the keyboard, simply by shifting its pitch!
Pitch-shifting algorithms can take a sound wave up or down an octave (or even a small fraction of an
octave, known as pitch) to create a usable range of that sample, much as though you were playing it
up and down the keys of a sampler keyboard or a synthesizer keyboard.
As you learned previously, the tone of a waveform can be determined by the frequency of that
waveform itself, so it becomes a fairly straightforward mathematical computation to be able to
accurately shift that pitch (wave) up an octave by shortening that wavelength by cutting it in
half, or shift the pitch down an octave by doubling that wavelength. Any fraction between these
two extremes changes the pitch of the audio sample, which is how you get different notes along
a keyboard using a single waveform. You can even create fractions between “known” pitches
(common notes such as A, B, D, F and G) which can be used to create “micro-tonal” music. Digital
audio synthesis is amazing!
SoundPool can perform pitch-shifting on your digital audio samples, which is why you are learning
about these concepts in this appendix, and it does have some impressive audio synthesis
capabilities and will probably add even more features in future versions of the Android OS.
You need to know these digital audio synthesis concepts in order to leverage what SoundPool can
do for your application effectively and optimally. If you need to use SoundPool, you will know how to
do it correctly, and you will now understand why you need to do it that way in the first place.
Another core audio synthesis mathematical manipulation is the combination, or compositing, of two
digital audio waveforms. This will allow the playback of two sounds at the same time, using a single
oscillator, or using the speaker hardware. Just as with digital imaging, 2D animation or digital video
compositing, this involves adding two different sample data values to arrive at the final data value.
Today’s Android audio hardware features impressive multi-channel support, and probably has the
capability of playing Stereo (two channels) or Quadrophonic (four channels) quality audio (effects,
music, vocal tracks, and so on) using the audio hardware that is inside any given consumer
electronics device.
But what if you want to combine six or eight tracks of digital audio in real-time, like an audio
sequencer can? This is why SoundPool is important to master, because it can provide you with a
digital audio sequencing engine right inside your Android application.
The Android SoundPool audio sequencing and synthesis engine is a complex class, as you might
well imagine, and to make it work properly, you need to give it the most highly optimized samples
possible. This class is in Android to stay, and its code will continue to be debugged, refined, and
improved, so if your Android app is going to be audio-centric, you need to master it. Chapter 12 gets
you up to speed on how to best use SoundPool, as well as what it can accomplish for your apps.