A (175)

(Tuis.) #1
447

Chapter 12


Digital Audio: Providing Aural


Feedback for UI Designs Using


SoundPool


In the previous chapter on digital video, we covered the Uri, MediaPlayer, and MediaController
classes, which you can also use with digital audio, which we are going to cover in this chapter.
Since these classes are used in the same exact way with digital audio assets, I am going to show
you how to use the Android SoundPool audio sequencing class in this chapter, so I can cover as
many of Android’s new media classes as possible in this book.


If you want to play long-form digital audio, such as songs, albums, or audio books, you would use
the Android MediaPlayer class along with the Android MediaController and URI classes, using the
SeekBar widget, instead of the VideoView. You could also loop long-form audio in the background,
without using the SeekBar widget!


If you want to play short-form digital audio, however, such as sound effects for your games or UI
elements for aural feedback, you would use the Android SoundPool class. The SoundPool “engine”
is actually more versatile than the MediaPlayer class is when it comes to controlling digital audio
assets. SoundPool is a powerful digital audio sequencing engine, and basically allows you to
composite audio, in the same way that you use layers in digital image compositing to composite
imagery. SoundPool is a complex and versatile digital audio class, upon which Android continues to
improve, so it’s a stretch for an Absolute Beginner!


Digital audio is a bit different from digital imagery and digital video as you can’t see it; you have to
rely on your ears. Instead of using waves of light, as color does, digital audio uses waves of sound,
and as such, the technical fundamentals are completely different. If you are new to digital audio,
Appendix A in this book will cover both the theory and the concepts behind digital audio, as well
as a plethora of digital audio codecs and file formats that are supported in Android, as well as what
each of them would be used for inside of an Android application.

Free download pdf