Audio recording format for iOS and Android devices with instant voice connectivity

Source: Internet
Author: User

Before I developed my iphone, I knew very little about the sound format. I know some of the differences between "wav" and "MP3" sound formats, but I certainly can't tell you exactly what the "AAC", "CAF" sound file is, and how the best way to convert audio files on your Mac is not known.

I know that if you want to be a qualified iphone developer, you have to have a basic understanding of sound file data format, conversion, recording, and what audio manipulation API to use.

This article is the first article in three audio development tutorials. In this article, we'll start with the file and data format.

File formats and data formats

The first thing we need to know is that there are two parts to each audio file: 1 is the file format (also called the Audio Container), and 2 is the data format (also called audio encoding).

The file format (or the audio container) describes the file in its own format. The actual audio data inside it can be encoded in many different ways. For example, a file with the suffix CAF is a file format that can contain audio data encoded in MP3, Linear PCM (LPCM), and many other formats.

Let's go a little deeper.

Data format (or audio encoding)

We're going to begin to understand the audio encoding, not the file format, because the audio encoding is the most important.

The following are the audio data encoding formats supported by the iphone and the descriptions for each:

· AAC:AAC is actually an abbreviation for "Advanced Audio Coding", which is designed to replace the MP3 format. You might think that it compresses the original sound, resulting in less capacity but the quality will certainly drop. However, the loss of these qualities depends on the size of the sound bit rate, which is hard to hear when the bitrate is appropriate. In fact, AAC has a better compression ratio than MP3, especially when the bit rate is below 128bit/s.

· HE-AAC:HE-AAC is a superset of AAC, and this "HE" stands for "high efficiency". HE-AAC is an audio encoding format optimized for low bit rates, such as streaming audio, which is particularly suitable for use in this encoding format.

· AMR:AMR full name is "Adaptive multi-rate", it is another specifically for the "speaking (speech)" Optimized encoding format, is also suitable for low bit rate environment to adopt.

· ALAC: Its full name is "Apple Lossless", which is an audio encoding without any loss of quality, which is what we call lossless compression. It is capable of compressing 40%-60% of raw data during actual use. This encoding format is very fast decoding, which is ideal for small devices like the iphone or ipod.

· ILBC: This is another audio encoding format specifically designed for speech, which is ideal for other applications where streaming audio is required, such as IP telephony.

· IMA4: This is a compression format that is compressed by a compression ratio of 4:1 under the 16-bit audio file. This is a very important encoding format on the iphone and we'll discuss why later.

· Linear PCM: Its Chinese meaning is based on linear pulse-coded modulation, which is used to convert analog sound data into digital sound data. In short, it means no compression data. Because the data is uncompressed, it can be played very quickly, and when space is not a problem, this is the preferred audio encoding on the iphone.

· Μ-law and A-law: As far as I know, this encoding is an alternating coded analog data for digital format data, but is better than linear PCM in speech optimization.

· MP3: This format is what we all know and like, although it's been a long time, but MP3 is still a very popular encoding format, and it can be well supported by the iphone.

What encoding format do we choose?

The above looks like a big table, but in fact there are only a few of us that are preferred for development. When making a specific choice, you must remember the following points:

· You can play linear PCM, IMA4 and some other uncompressed or simple compressed audio formats that are well decoded by the iphone's hardware.

· For more advanced compression formats, such as Aac,mp3, and Alac,iphone do not provide support for hardware codecs to quickly decompress the data, and only one file can be processed at a time. Therefore, if you play more than one audio file using these encodings, the system will choose to use the software to decode it, which will be slower and CPU intensive.

So what data format to choose, here are two tips:

· If space is not a problem, use linear PCM to encode each audio. This not only makes your audio play as quickly as possible, but you can play multiple sounds at the same time without consuming CPU resources.

· If space is a problem, you will most of the time use AAC to encode your background music and IMA4 to encode your sound.

Many variants of the Linear PCM

Another important issue with linear PCM needs to be emphasized is that this uncompressed data format is the preferred programming option on the iphone. There are some linear PCM variants for different data stores. The data can be stored in high mantissa or low mantissa format, and the difference between them is like floating-point and integral types that occupy a different bit width.

The most important thing here is that the preferred linear PCM on the iphone is a 16-bit integer in the low mantissa (Little-endian) format, or "Lei16″ (as if it were an encoding format, Apple CAF audio format code: LEI16, the audio format for iOS devices is 16-bit low mantissa encoding). This is not the same as Mac OS X, which uses a local 32-bit floating-point mantissa encoding. Because audio files are often created on Mac, it's a good idea to check the files and convert them to the preferred audio encoding format for the iphone.

File format (or audio container)

The iphone supports many file formats, including MPEG-1 (. mp3), MPEG-2 ADTS (. aac), AIFF, CAF, and WAVE. But the most important thing is that you can only use CAF, because it can contain any iphone supported encoding format data, on iphone it is recommended file format.

(Translator: Here I am wordy point, in fact, the file format is like a bucket, which can contain a lot of water, those water is the audio data. There are many kinds of barrels, that is, there are many kinds of file formats, and different barrels, but also need to be loaded with water. The CAF can be filled with all kinds of water, but some can only be filled with several types of water. I hope you can understand this metaphor very well. )

Bit rate

Here's a term that's important for audio coding, and we'll talk about it next: bit rate.

The bit rate is the number of bytes (bits) that the audio file occupies per second. Some encoding like AAC or MP3 specifies the number of bits of audio file compression. When you are using a lower bit rate, you will lose sound quality.

You should choose different bitrate based on the specific sound file, try to compare which one is the most suitable, and make some tradeoffs between the sound file size and the sound quality by using different bit rates. If your files are mostly voice-speaking data, you can use a lower bit rate.

Here is a table that gives you an overview of the most common bit rates:

· 32KBIT/S: The quality of amplitude modulation (AM) broadcasts

· 48KBIT/S: General bitrate for long-time voice podcasts

· 64KBIT/S: Bitrate for general normal-length voice podcasts

· 96KBIT/S: Quality of FM (FM) broadcast

· 128KBIT/S: Bit rate for most MP3 music

· 160KBIT/S: Those who like music, who want to hear more, prefer a bit rate above 128kbit/s

· 192KBIT/S: Quality of digital radio

· 320KBIT/S: At this bit rate, people are almost as effective as CD playback.

· 500KBIT/S-1,411KBIT/S: Lossless audio encoding, just like linear PCM

Sample Rate

Before we go on with the audio, here's another term we need to know: sample rate.

When converting an analog signal to a digital format, the sample rate indicates how often a sound waveform sample is drawn to convert to a digital signal.

In most cases, 44100Hz is often used because of the same sample rate as CD audio.

Disclaimer (Must read!) ): All of the tutorials provided in this blog are translated from the Internet for learning and communication purposes only and should not be commercially disseminated. Also, do not remove this statement when reproduced. In case of any dispute, there is no relationship between the blogger and the person who published the translation. Thank you for your cooperation!

Original link Address: http://www.raywenderlich.com/204/audio-101-for-iphone-developers-file-and-data-formats

The solution of each recording format is summarized as follows:

Mp3:ios,android recording requires encoding conversion, using lame third-party library, playback should be able to play directly

Ilbc:ios support encoding decoding, Android low version is not supported, but there is open source third-party library, can be recorded encoding, playback decoding processing

Speex: Also open source third-party library, claiming that the file is small, can reduce noise, need to ios,android the client to encode and decode processing

Amr:ios versions prior to 4.3 support, later versions do not support AMR format, the Android device supports this format, the iOS device can be converted Libopencore third-party libraries, playback and then decoded to the original PCM for playback. Android devices can be recorded and played directly

AAC: Both systems should support the format, but there are said Android devices are not good enough to support. No tests were made, the details are unknown.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.