454 CHAPTER 12: Digital Audio: Providing Aural Feedback for UI Designs Using SoundPool
the digital audio asset in the Java code that we’ll be writing in the next section of the chapter, after
we go through a data footprint optimization process using six audio formats which are supported in
Android, including WAV (baseline), FLAC, OGG, MP3, M4A, and AMR (or 3GP).
Exporting Uncompressed PCM Baseline WAV Format
To export a file in Audacity, we’ll use the File ➤ Export menu sequence to open the Export File
dialog shown in Figure 12-8. This dialog has several key areas, including the Save in folder specifier,
which I have pointing to my CH12 book assets folder; the File List Pane, which shows the original
button_sound_effect.wav file; the File name: data entry field where we will name our file, in this
case buttonaudio; and underneath that, the Save as type: drop-down selector, which contains
all the file formats that Audacity will export to, given that we have correctly installed the LAME and
FFmpeg codec libraries. Notice that I have this Export File dialog set to export buttonaudio.wav in
WAV (Microsoft) signed 16-bit PCM format, which is why I do not need to specify the .wav extension
part of the file name.
Figure 12-8. Exporting a baseline 16-bit PCM WAV format file, and the Edit Metadata Dialog shown in all exports
If you click on the Options button, which is located in the bottom-right corner of the Export File
dialog, you will see that for the Wave audio file format, you’ll get a dialog that informs you that there
is no encoding option for a PCM file. This is because Wave contains uncompressed data, just like
the full frames uncompressed AVI file did in the previous chapter.
Once you click on the Save button, an Edit Metadata Dialog will appear, as shown in the middle
in Figure 12-8. The dialog has data fields for text values for Artist Name, Track Title, Album Title,
Track Number, Year, Genre, and Comments. Since I am optimizing here for the baseline data
footprint, and our application does not require audio metadata, I am leaving these fields blank for
now, so that we can get an accurate read on what the precise file size is; that is, the size of a file
containing only the audio data. If you are wondering if Android OS can read, and therefore support,
audio metadata if you did want to put this data into your audio files, the answer is a resounding YES!
Android has a MediaMetadataRetriever Class, which developers can utilize for this very specific
purpose. If, for some reason, your audio application needs to leverage audio media metadata, you
can use an Edit Metadata dialog, which will show itself every single time you save any type of audio
file format in Audacity 2.0.5, along with the Android MediaMetadataRetriever Class, which you can
research and learn about at the following URL:
http://developer.android.com/reference/android/media/MediaMetadataRetriever.html