A (175)

(Tuis.) #1
CHAPTER 12: Digital Audio: Providing Aural Feedback for UI Designs Using SoundPool 465

Navigate to the project /res/raw folder, right-click, and click Paste to paste the three audio assets,
as seen in Figure 12-18.


Figure 12-18. Paste any of the three buttonaudio samples of your choice into your HelloUniverse/res/raw folder


Notice in Figure 12-17 that even Windows Explorer gets things wrong, as it is listing Ogg Vorbis
audio assets as being Opera browser audio assets! As developers, we must always be smarter than
the tools that we utilize!


Make sure your buttonaudio, buttonaudio2, and buttonaudio3 files all use one codec type and that
you don’t have files of the same name with a different codec in the folder. I used FLAC and M4A to
test the code for this chapter, but because Android only looks at the first part of the file name, if you
have more than one codec version installed in your /res/raw folder at any given time for these file
names, the Eclipse environment will throw an error message, or more than one error message, if you
copy all of your codec versions into the /res/raw folder all at once. If you want to do this, be sure to
rename the files first, using the codec type as part of the file name; for instance, you might name the
unused files: buttonaudioflac, buttonaudiovorbis, or buttonaudiompeg4.


Now you have the Java objects and digital audio assets in place to be able to finish wiring up your
SoundPool engine. Make sure that after you copy the three audio (codec) formats that you want to
use, you right-click on your project folder, and use the Refresh command, so that Eclipse can see the
new files. I was using MPEG-4 audio assets when I took the screenshot shown in Figure 1 2-1 9 , as
you can see on the left side of the screen, in the /res/raw folder. We are going to use a fairly complex
Java construct to load our SparseIntArray object, while at the same time, loading the digital audio
resource into the SoundPool object. As you may have noticed, I’m going to use more advanced
concepts and constructs as this book progresses, so that you progress with it!

Free download pdf