IPhone audio 101 (Part 1): file and Data Types

Source: Internet
Author: User

IPhoneDeveloped audio 101 (Part 1): file and Data Types

 

Translator: Xia laiyou

 

Disclaimer (read only !) : The original translations of all tutorials provided by this blog are from the Internet and are only for learning and communication purposes. Do not conduct commercial communications. At the same time, do not remove this statement when reprinting. In the event of any dispute, it has nothing to do with the owner of this blog and the person who published the translation. Thank you for your cooperation!

 

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

 

Before using the iPhone, I knew a lot about sound formats. I only know the differences between "WAV" and "MP3", but in any case, I cannot tell you exactly what type "AAC" and "caf" are, it cannot tell the best way to convert audio files on Mac.

I have learned a little about audio. If you want to develop audio on the iPhone, you should have a basic understanding of file and data formats, conversion, recording, and APIs.

This articleArticleThis is the first of three audio development tutorials. In this article, we will start with the file and data format.

 

File Format and Data Format

 First, we need to know that each audio file has two parts: 1 is the file format (or audio container), 2 is the data format (or audio encoding ).

The file format (or audio container) describes its own format. The actual audio data can be encoded in many different ways. For example, a caf file is a file format that can contain audio data encoded in MP3, linear PCM (lpcm), or many other formats.

Next let's take a deeper look.

 

Data format (or audio encoding)

We will actually begin to understand audio encoding, not file encoding, because this encoding is actually the most important part.

The following are the data formats supported by the iPhone and descriptions for each:

    • AAC: AAC is actually "Advanced Audio Coding", a successor designed as MP3. You may guess that it compresses the original sound, resulting in low capacity usage but reduced quality. However, this loss quality is hard to be noticed at the bit rate you set. In fact, AAC has a better compression rate than MP3, especially at the same bit rate.
    • HE-AAC: HE-AAC is an extension of AAC, this "he" is actually "high efficiency ". The HE-AAC is the best audio at low bit rates, just like streaming audio.
    • AMR: AMR is actually "adaptive multi-rate", which is another fast and effective encoding method at low bit rates.
    • ALAC: it is actually "Apple lossless". This is a method of encoding audio without any quality loss, that is, lossless compression.
    • Ilbc: This is another highly efficient and fast encoding method for VoIP and streaming audio.
    • Ima4: This is a compression format that compresses 16-bit audio files. This is a very important encoding for the iPhone and we will discuss the reason later.
    • Linear PCM: this is based on linear pulse encoding modulation and introduces the technology used to simulate the conversion of audio data into digital formats. In short, it means no data compression. Since the data is not compressed, it can play very quickly, and when the space is not a problem, this is the preferred audio encoding method on the iPhone.
    • μ-law and a-law: As far as I know, this encoding is an alternative code to simulate data to a digital format, but it is faster than linear PCM.
    • MP3: This format is a popular one that we all know and like. MP3 is also well supported by the iPhone.

 

What should we choose?

The above looks like a large table, but only some of them are our first choice for encoding. To know what we use, remember:

    • You can play linear PCM, ima4, and some other formats without compression, simple compression, and no problem at the same time. These formats can be well decoded by iPhone hardware.
    • For more advanced compression formats, such as AAC, MP3, and ALAC, the iPhone does not have hardware support to quickly decompress the data and can process only one file at a time. Therefore, if you play more than one audio encoding method, they will use the software to decode the audio, so it is very slow and will occupy the CPU.

Therefore, there are two suggestions for choosing the data format:

    • If the space is not a problem, use linear PCM to encode each audio. This not only enables you to play the fastest audio, but also enables you to play multiple sounds without occupying CPU resources at the same time.
    • If space is a problem, most of you will use AAC to encode your background music and ima4 to encode your sound effects.

Linear PCMMany differences

One important thing about linear PCM is to declare that this uncompress data format is preferred for the iPhone. For different data storage, there are some different linear PCM. These data can be stored in high or low byte sequence formats, such as floating point type, integer type, or various bit widths.

The most important thing to know is that the preferred linear PCM on the iPhone is a 16-bit integer with a low byte order, or "lei16" (it seems like a encoding format, apple caf audio format code: lei16. The audio format of iOS devices is 16-bit low-byte encoding ). This is different from Mac OS X. It uses a 32-bit floating-point byte sequence. Because audio files are often created on Mac, it is a good idea to check files and convert their preferred formats to the iPhone.

 

File Format (or audio container))

IPhone supports many file formats including MPEG-1 ((), 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 encoding format data supported by the iPhone. On the iPhone, it is the recommended file format.

Here I am talking about it. In fact, the file format is like a bucket, which can hold a lot of water and the water is the audio data. There are many types of buckets, that is, there are many file formats, and different buckets also need different water. The CAF bucket can hold a variety of water, but some can only hold several types of water. I hope you can better understand this metaphor.

 

Bit Rate

This is a term important to audio encoding, which we will mention next: bit rate.

The bit rate is the number of bytes (BITs) occupied by audio files per second ). For example, AAC or mp3 encoding specifies the number of BITs compressed by the audio file. When you make this bit rate relatively low, you will lose the quality.

You should choose different bit rates based on your special audio files, and try to use different bit rates to see which one is most appropriate in terms of file size and quality. If most of your files are speech, you can use a relatively low bit rate.

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

    • 32 kbit/s: the quality of AM broadcast
    • 48 kbit/s: Generally, the bit rate of a long-time speech podcast.
    • 64 kbit/s: the bit rate of normal-length speech podcasts
    • 96 kbit/s: quality of FM Broadcast
    • 128 kbit/s: Bit Rate of most MP3 music
    • 160 kbit/s: A bit rate higher than 128 kbit/s that people who like music and want to hear.
    • 192 kbit/s: Digital station quality
    • 320 kbit/s: At this bit rate, people play almost the same effect as CD.
    • 500 kbit/S-1, 411 kbit/s: lossless audio encoding, like linear PCM

 

Sampling Rate

Before we continue to introduce the audio, we need to know the terms "Sampling Rate.

When a analog signal is converted to a digital format, the sampling rate indicates how often the acoustic waveform sample is extracted to convert it into a digital signal.

In most cases, 44100hz is frequently used because it is the same as the sampling rate of CD audio.

 

Next we will discuss how to convert audio files and record audio files on Mac.

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.