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

Source: Internet
Author: User

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

 

This tutorial is composedHeroes come by themselvesAlsoTranslation, tairanForum translation GroupProofread, thanksYou are here!

 

Before developing the iPhone (Ray) Has little knowledge about the sound format. I knowSome "WAV"And"MP3"Differences in sound formats, but I cannot tell you exactly"AAC","Caf"What isAudio files in MAC formatThe best way to convert audio filesWhat is it.

I know that if you want to become a qualified iPhone developer, you must format, convert, record, and use audio operation APIs for audio file data.Have a basic understanding.

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:1Is the file format (Audio container ),2Is the data format (Audio Encoding ).

The file format (or audio container) describes its own format. The actual audio data in it can be encoded in many different ways. For example, a file suffixed with CAF is a file format that can containMP3, LinearPCM(Lpcm)And audio data encoded in many other formats.

Next let's take a deeper look.

Data format (Audio Encoding)

Next we will begin to understand audio encoding, not file format, because audio encoding is the most important thing.

Below isIPhoneSupportedAudio data encoding format and description for each:

  • AAC : AAC actually the abbreviation of" Advanced Audio Coding "is designed to replace the MP3 format. You may think that it compresses the original sound, resulting in low capacity usage but the quality will definitely decrease. However, the loss of these quality depends on the sound bit rate. When the bit rate is suitable, the loss is hard to hear. In fact, AAC ratio MP3 better compression rate, especially when the bit rate is less than 128bit/S .
  • HE-AAC:HE-AACYesAACOneSuperset, this"He"It indicates "high efficiency ". HE-AAC is a kind of audio encoding format specially optimized for low bit rate, such as streaming audioThis encoding format is particularly suitable.
  • Amr:AmrFull name:"Adaptive multi-rate",It is also another speech)"The optimized encoding format is also suitable for Low Bit Rate environments.
  • ALAC: ItFull name:"Apple lossless"This is an audio encoding method without any quality loss, that is, lossless compression.In actual use, it can be compressed by 40%-60%. The decoding speed of this encoding format is very fast.IPhoneOrIPodThis is suitable for small devices.
  • Ilbc:This is anotherAudio Encoding format specially designed for speech, which is very suitable for IP addressesPhones and other scenarios that require streaming audio.
  • Ima4: This is16-bitFor audio files, follow4:1CompressionThe compression format of the ratio. This isIPhoneThe preceding very important encoding format will be discussed later.
  • Linear PCM:It is a linear pulse-coded modulation used to convert analog sound data into digital sound data. In short, it means no data compression. Because the data is not compressed, it can be played very quickly, and when the space is not a problem, this isIPhoneThe preceding audio encoding method is preferred.
  • μ-law and a-Law: As far as I know, this encoding is an alternate code simulation data.Data is in numeric format, but compared with speech OptimizationLinear PCMBetter.
  • · MP3: We all know and like this format,Although many years have passed, MP3 is still a very popular encoding format so far, and it can also beIPhoneGood.
What encoding format should we choose?

The above seems to be a large table, but only some of them are the first choice for development. When making specific choices, you must remember the following points:

    • You can playLinear PCM,Ima4And some others without compressionOr a simple compressed audio format, which can be wellIPhoneHardware decoding.
    • For more advanced compression formats, suchAAC,MP3, AndALAC,IPhoneHardware codecs are not provided 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 the encoding, the system will use the software to decode it, which will be slow and occupyCPU.

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

    • If the space is not a problem, useLinear PCMTo encode each audio. This not only makes your audio the fastestAnd you can playCPUResourcePlay multiple sounds at the same time.
    • If space is a problem, you need to use it most of the time.AACTo encode your background music andIma4To encode your sound effect.
Linear PCM Many Variant

There is also a very importantLinear PCMOfThe problem should be emphasized that this non-compressed data format is preferred for programming on the iPhone. There are some linear PCM variants for different data storage. These data can be stored in the high-tail or low-tail format. The differences between them are like the bit widths occupied by floating point and integer types.

The most important thing here is IPhone The above preferred Linear PCM Is low In the little-Endian format 16 Integer, or "Lei16 "( It seems to be an encoding format, Apple caf audio format code : Lei16, IOS The device audio format is 16 Low Bit Tail code ) . This is Mac OS X The difference is that it uses local 32 Bit floating point type Tail number encoding. Because audio files are often stored in Mac Created above, so check the file And convert them to iPhone Preferred Audio Encoding format is a good idea.

File Format (audio container)

IPhoneSupports many file formats, includingMPEG-1 (iff), MPEG-2 ADTS (. AAC), AIFF, caf, and wave. But the most important thing is that you canUse onlyCAFBecause it can contain anyIPhoneSupported encoding format data, inIPhoneThe above is the recommended file format.

Here I am talking about it. In fact, the file format is like a bucket. There is a lot of water in it, 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.CAFThis 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 ). Some imagesAACOrMP3Encoding specifies the number of BITs compressed by the audio file. When youWhen using a low bit rate, you will lose the sound quality.

You should select different bit rates based on the specific audio files, and try to use different bit rates to compare which one is the most suitable, weigh the sound file size and sound quality. If most of your files are speech data, 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:AM(AM) broadcast quality
  • 48 kbit/s:Generally, the bit rate of a speech podcast is relatively long.
  • 64 kbit/s:The bit rate of normal-length speech podcasts.
  • 96 kbit/s:FM(FM) broadcast quality
  • 128 kbit/s:MajorityMP3Bit Rate of music
  • 160 kbit/s:Those who like music and want to hear more128 kbit/sA bit rate above
  • 192 kbit/s:Digital Radio quality
  • 320 kbit/s:At this bit rate, people almost matchCDThe playback effect is the same and cannot be different.
  • 500 kbit/S-1, 411 kbit/s:Lossless audio encoding, likeLinear 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,44100HzIs frequently used, becauseCDThe same sampling rate for audio.

 

For more iPhone audio format and audio operation articles, go to the homepage of Daxia.

 

To communicate with the Forum, click the portal!

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.