656 APPENDIX A: Audio Concepts, Terminology, and Codecs
It is important to note that MP3 is a lossy audio file format, like JPEG is for images, where some of
the audio data (and thus quality) is thrown away during the compression process and cannot be
recovered. Android does have a lossless audio compression codec, called FLAC, which stands for
Free Lossless Audio Codec. FLAC is an open source audio codec whose support is as widespread
as MP3, due to the free nature of the software decoder.
FLAC is also very fast, so the decoder is highly optimized for speed, it supports 24-bit HD audio,
and there are no patent concerns for using it. This is a great audio codec to use if you need very
high-quality audio within a reasonable data footprint. FLAC supports a wide range of sample
resolutions, from 4-bits per sample up to 32-bits. It also supports a wide range of sampling
frequencies—from 1Hz to 65,535kHz (65kHz), in 1Hz increments—so it is extremely flexible.
From an audio playback hardware standpoint, I would suggest using the 16-bit sample resolution
and either a 44.1kHz or 48kHz sample frequency. FLAC is supported in Android 3.1 and later, so if
your users are using modern Android devices, you should be able to safely utilize a FLAC codec.
Therefore, it is possible to use completely lossless new media assets in your Android application,
using PNG32 and FLAC, as long as you are targeting Android Version 3.1 and later OS revisions.
Another open source digital audio codec supported by Android is the OGG Vorbis codec, another
lossy audio codec from the Xiph.Org Foundation. The Vorbis codec data is most often held in an
.OGG data file container, and thus Vorbis is commonly called OGG Vorbis digital audio data format.
The OGG Vorbis supports sampling rates from 8kHz up to 192kHz, and supports up to 255 discrete
channels of digital audio (as you now know, this represents 8-bits worth of audio channels). OGG
Vorbis is supported in all versions of the Android OS.
Vorbis is quickly approaching the quality of HE-AAC and WMA (Windows Media Audio) Professional,
and is superior in quality to MP3, AAC-LC, and WMA. It is a lossy format, so the FLAC codec is
superior to OGG Vorbis, as it contains all of the original digital audio sample data (as it is lossless).
Android supports most popular MPEG4 AAC (Advanced Audio Coding) codecs, including AAC-LC,
HE-AAC, and AAC-ELD. These can all be contained in MPEG4 containers (.3gp, .mp4, and .m4a) or
file extensions, and can be played back across all versions of Android.
The one exception to this is the AAC-ELD, which is supported only after Android 4.1. ELD stands for
Enhanced Low Delay, and this codec is intended for usage in a real-time, two-way communications
application, such as a digital walkie-talkie.
The simplest and most widely used AAC codec is the AAC-LC or Low Complexity codec. It should
be sufficient for most digital audio encoding applications. An AAC-LC should yield a higher quality
result at a lower data footprint than the MP3 format. The next most complicated AAC codec is the
HE-AAC or High Efficiency AAC codec. This codec supports sampling rates from 8kHz to 48kHz,
and both Stereo and Dolby 5.1 channel encoding. Android supports decoding both the v1 and v2
levels of this codec, and Android will also encode audio using the HE-AAC v1 codec in Android
devices later than Version 4.1 (Jelly Bean). Use the AAC-LC codec to support the earlier versions of
the Android OS.
For encoding speech, which usually features a different type of sound wave than music, there are
two other AMR or Adaptive Multi-Rate audio codecs. They are highly efficient for encoding things
like speech or short-burst sound effects that do not need high-quality reproduction (such as a bomb
blast sound effect). There is also the AMR-WB (Adaptive Multi-Rate Wide-Band) standard in Android,