[Fixed] avaudiorecorder recording and Encoding Problems

Source: Internet
Author: User
Hello everyone, I want to use Avaudiorecorder implements the recording playback function.

Nsmutabledictionary * recordsetting = [[nsmutabledictionary alloc] init];

[Recordsetting setvalue: [nsnumber numberwithint: kaudioformatamr] forkey: avformatidkey];

[Recordsetting setvalue: [nsnumber numberwithfloat: 44100.0] forkey: avsampleratekey];

[Recordsetting setvalue: [nsnumber numberwithint: 2] forkey: avnumberofchannelskey];


Nsarray * paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory,

Nsuserdomainmask, yes );

Nsstring * documentsdirectory = [paths objectatindex: 0];

Recordedtmpfile = [nsurl fileurlwithpath: [documentsdirectory stringbyappendingpathcomponent: [nsstring stringwithformat: @ "test % d. % @", 01, @ "caf"];

Recorder = [[avaudiorecorder alloc] initwithurl: recordedtmpfile settings: recordsetting error: & error];

[Recorder setdelegate: Self];

[Recorder preparetorecord];

[Recorder Record];



Red partCodeThe iPhone SDK only supports several encoding formats, not including
KaudioformatamrI want to know what format is used for recording. When sound effects are guaranteed, should the recording file be kept as small as possible?

 

Below are some audio playback formats supported by iPhone OS:

AAC
HE-AAC
Amr (Adaptive multi-rate, which is a speech format)
ALAC (Apple lossless)
Ilbc (Internet low bitrate codec, another voice format)
Ima4 (IMA/ADPCM)
Linear PCM (no compression)
Micro-law and a-Law
MP3 (MPEG-1 audio layer 3rd)
Below are some audio recording formats supported by iPhone OS:

ALAC (Apple lossless)
Ilbc (Internet low bitrate codec for voice)
Ima/ADPCM (ima4)
Linear PCM
Micro-law and a-Law
The following list summarizes how iPhone OS supports single-or multi-channel audio formats:

Linear PCM and ima4 (IMA/ADPCM) on the iPhone OS, you can play multiple linear PCM or ima4 sounds at the same time without causing CPU resources problems. This also applies to the audio quality formats of AMR and ilbc, as well as the micro-law and a-Law compression formats. When using the compression format, check the sound quality to meet your needs.
AAC, MP3, and ALAC (Apple lossless) AAC, MP3, and ALAC sound playback can use efficient hardware decoding on the iPhone OS device, but these codecs share a hardware path, through hardware, the device can only play one of the above formats at a time.
The fact that AAC, MP3, and ALAC share the same hardware path for playback will be applied to the "Cooperative playback" style.ProgramSuch as virtual piano. If you play audio in one of the three formats on your iPod program, your application-if you want to play audio with the audio-requires software decoding.

 

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.