What audio format does Android use?

Android has supported various audio formats since its initial release in 2008. The earlier versions of Android mainly relied on MP3 and MIDI for audio playback. With each new version release, support for additional formats was added. Some of the key developments include:

Android 2.3 Gingerbread introduced support for AAC and Ogg Vorbis in 2010 [1].

FLAC support was added in Android 3.1 Honeycomb in 2011 [2].

More recently, Android 10 added support for MIDI 2.0 and high-resolution lossless audio with Android 11 in 2020 [3].

Today, the most commonly supported formats on Android devices are MP3, AAC, FLAC, MIDI, WAV, and Ogg Vorbis. These provide options for high-quality compressed audio, lossless compression, sequencing, and uncompressed PCM audio.

[1] https://en.wikipedia.org/wiki/Android_version_history
[2] https://developer.android.com/media/platform/supported-formats
[3] https://source.android.com/docs/core/audio/data_formats

Android Audio Architecture

The Android audio architecture consists of both high-level and low-level components that work together to handle audio functionality on Android devices. At a high level, the architecture includes the AudioFlinger service, Media Server, and Audio Policy Service.

The AudioFlinger is the audio mixing engine that handles audio streams and effects processing. It interacts with the hardware audio driver and mixes together all audio streams before sending the final mix to the hardware. The AudioFlinger runs in its own process to isolate audio from other system components.

The Media Server handles decoding compressed audio formats into raw PCM audio that can be mixed by the AudioFlinger. It supports formats like MP3, AAC, OGG, FLAC, MIDI, WAV, and more. The Media Server runs in the mediaserver process.

The Audio Policy Service acts as the global audio policy manager. It defines audio routing policies and audio profiles for different use cases like voice calls, media playback, alarms, etc. The audio policy helps route audio to appropriate outputs and applies audio effects.

At a lower level, the audio hardware abstraction layer (HAL) interacts with the actual audio hardware drivers and handles the low-level audio input/output. Different hardware implementations will have their own audio HAL implementations.

The overall architecture provides a flexible system to handle the various audio requirements on an Android device, mixing streams and routing audio appropriately based on defined policies. The modular design isolates audio processes and allows for hardware-specific implementations via the audio HAL.

MP3

MP3 (MPEG-1 Audio Layer III) is one of the most popular audio formats used on Android devices. It utilizes lossy compression, which reduces audio file size by eliminating certain parts of the sound that are considered beyond the auditory capabilities of most people. The typical MP3 audio file is compressed to about 1/10 the size of the original uncompressed audio.

MP3 uses perceptual audio coding techniques that remove redundant and irrelevant sounds from the audio. The frequencies are analyzed and split into multiple sub-bands, with each sub-band quantized and encoded to use fewer bits per sample. This allows the format to heavily compress the audio while still retaining most of the information that the human ear can perceive.

Since its introduction in 1993, MP3 has become the de facto standard audio format for consumer audio storage, especially in portable devices. Most Android devices have built-in support for MP3 playback. The Android media framework includes a MP3 decoder, and the native Music player app can play MP3 files. MP3 support is also built into the Android SDK to allow developers to easily integrate MP3 playback into their apps.

MP3s can be copied directly to an Android device’s internal storage or SD card. Apps like Google Play Music will scan and catalog the MP3 files, making them available alongside streaming music. There are also many third party apps that support downloading and playing MP3 files on Android.

AAC

AAC (Advanced Audio Coding) is an audio compression format developed by Fraunhofer IIS that was designed to be the successor to MP3. AAC achieves better audio quality than MP3 at similar bit rates.

AAC uses perceptual audio coding and psychoacoustic models to discard or reduce the precision of components less audible to human hearing. It supports up to 48 channels and sample rates up to 96 kHz. AAC is widely supported on modern smartphones, media players, gaming consoles and streaming services.

AAC has broad support across the Android ecosystem. Android has included native support for AAC since Android 2.3 Gingerbread, released in 2010. The Android media framework provides encoders and decoders for AAC so it can be used for recording and playback in apps. Popular music apps like Spotify, Apple Music and YouTube Music all use AAC as the primary audio format on Android.

Android also supports high efficiency AAC (HE-AAC) and AAC+ formats that provide better quality at low bitrates. Overall, AAC offers an excellent combination of quality and efficiency for audio on Android devices.

Ogg Vorbis

Ogg Vorbis is an open-source audio compression format. It uses Vorbis compression algorithms to encode audio with relatively small file sizes while maintaining high quality. Ogg Vorbis is different from other formats like MP3 and AAC in that it is completely free and open source.[1]

Ogg Vorbis uses lossy compression, meaning some data is discarded during encoding to reduce file size. However, it is designed to compress audio while causing imperceptible changes in quality. Ogg Vorbis files are smaller than equivalent WAV or FLAC files and comparable in size to other compressed formats like MP3 and AAC.

Android has included native support for Ogg Vorbis audio since Android 1.0. The Android media framework and standard media APIs can decode and play back Ogg Vorbis files without any additional software. This makes Ogg a convenient choice for Android audio applications looking for an open-source alternative to proprietary formats.[2]

FLAC

FLAC (Free Lossless Audio Codec) is an audio coding format for lossless compression of digital audio. Unlike lossy formats like MP3, FLAC does not remove data from the audio stream.

FLAC was designed for efficient compression, not playback, and supports up to 8 channels of audio at up to 655350 Hz sample rates. Audio compressed with FLAC can typically be reduced to 50–60% of its original size.[1]

FLAC uses linear prediction to convert the audio samples into a faster-to-encode form. It then generates a stream of metadata that includes the constant values, the factors needed to restore the original audio, and error correction codes.[2]

FLAC has native support on Android through the Android Open Source Project. Most Android devices can playback FLAC files out-of-the-box. However, support may vary across different versions of Android and device manufacturers. Some popular Android music apps like Poweramp, Neutron, and VLC have excellent FLAC support and are recommended for optimal playback.[3]

Overall, FLAC is widely supported on Android, but device and app compatibility should be checked, especially on older versions of Android.

Sources:

[1] https://www.videoconverterfactory.com/tips/play-flac-on-android.html

[2] https://www.reddit.com/r/audio/comments/17bxo7a/wich_is_the_best_android_app_to_listen_to_flac/

[3] https://videoconverter.iskysoft.com/play-video/android-play-flac.html

WAV

WAV is an uncompressed audio format developed by Microsoft and IBM. WAV files contain uncompressed PCM audio data and allow high-quality audio reproduction. However, the uncompressed nature of WAV files means they tend to take up significant storage space compared to compressed formats.

WAV audio is encoded in LPCM format, which means it stores the raw sample data without any compression. The samples are stored at various bit depths such as 8-bit, 16-bit, 24-bit, and 32-bit. Higher bit depths allow greater dynamic range. WAV files also support various sample rates from 8kHz to 192kHz.

Android has supported playback of WAV files since Android 1.0. The native Android media APIs allow apps to decode and play back uncompressed WAV files. However, some OEMs modify the software on their devices, which can lead to incompatibility issues with WAV playback on certain models. For example, some Samsung devices may not properly support WAV files over 20MB in size [1]. But overall, most modern Android devices can play back standard WAV files without issue.

MIDI

The Musical Instrument Digital Interface (MIDI) is a technical standard that allows electronic musical instruments, computers, and other equipment to connect and communicate with each other. MIDI carries event messages that specify notation, pitch, velocity, vibrato, panning, cues, and clock signals to synchronize tempo between multiple devices. MIDI messages and data can be transmitted over various cables or wirelessly.

MIDI has been supported on Android from the early days, with the android.media.midi package providing APIs for sending and receiving MIDI messages. Apps can check for MIDI feature support at runtime using methods like hasMidiFeature(). The Android MIDI architecture allows apps to act as MIDI hosts for connected MIDI devices like keyboards, drum machines, and more. MIDI data can be sent over USB or Bluetooth.

There are many examples of MIDI apps on Android, from simple MIDI event viewer tools to full music studio apps supporting MIDI sequencing, synth engines, and more. Some recommend best practices are requesting the BLUETOOTH_CONNECT permission, checking API levels, handling MIDI input properly, and optimizing for low latency.

Recommended Formats

When choosing an audio format for Android devices, there are a few key factors to consider:

Audio quality – Formats like FLAC and WAV provide lossless audio quality, while Ogg Vorbis, AAC, and MP3 use lossy compression for smaller file sizes. For casual listening, a high bitrate AAC or MP3 will provide excellent quality.

File size – FLAC and WAV files are much larger, while MP3 and AAC provide good quality at smaller file sizes. This is important for mobile devices with limited storage.

Compatibility – Nearly all Android devices support playback of MP3 and AAC files natively. FLAC and Ogg Vorbis also have good support. WAV and MIDI require additional apps for playback on some devices.

Metadata – MP3, FLAC, and AAC include support for tags like artist, album, title etc. This makes library organization easier.

Based on these factors, the recommended formats for Android are:
– MP3 – Nearly universal support, good quality at smaller sizes.
– AAC – Great quality and support, smaller files than MP3.

– Ogg Vorbis – Open source alternative with excellent quality.
– FLAC – For lossless quality when file size is not an issue.

While WAV, AIFF, and other uncompressed formats provide the highest quality, their large file sizes make them impractical for mobile use. Lossy formats like MP3, AAC, and Ogg Vorbis offer a good balance of quality and file size.

Conclusion

To summarize the key points, Android supports a wide variety of audio formats including MP3, AAC, Ogg Vorbis, FLAC, MIDI, and more. The most commonly used formats are MP3 for music and AAC for video. Android’s audio architecture has evolved over time to support increasingly higher quality audio experiences. The native audio APIs make it easy for developers to work with audio in their apps. Choosing the right format involves balancing quality, file size, compatibility, and licensing considerations. The recommended formats are AAC for most uses, MP3 for maximum compatibility, and Ogg Vorbis or FLAC for open source. With all the options available, Android provides flexible audio capabilities to power immersive media experiences on mobile.

Leave a Reply

Your email address will not be published. Required fields are marked *