Why should the recording alone to write, just because this is relatively simple, but because he is relatively simple, causing me a long time to ignore it, but when I think of it, suddenly forget I have learned this thing, in this, really is to think of all a little blush .... -。 -! ;
Recording:
Related class Description:
(1) Avaudioplayer
(2) Setting
<1>avnumberofchannelskey Number of channels
<2>avsampleratekey Sample Rate 44100
<3>avlinearpcmbitdepthkey bit LV 16 32
<4>avencoderaudioqualitykey Quality
<5>avencoderbitratekey bit sampling LV 128000
(3) Use
1. Initialization
2. Start recording
3. Stop Recording
Nonsense not much to say, we directly on the code;
How to Record
-(void) Startaudiorecoder: (UIButton *) sender{
/**
URL: is a local url,recodeer requires a stored path
*/
sender.selected =!sender.selected;
if (Sender.selected!=yes) {
[Recorder stop];
Return
}
NSString * name = [NSString stringwithformat:@ "%d.aiff", (int) [NSDate date].timeintervalsince1970];
NSString *path = [[Nssearchpathfordirectoriesindomains (Nscachesdirectory, Nsuserdomainmask, YES) LastObject] Stringbyappendingpathcomponent:name];
Nserror *error;
Recorder = [[Avaudiorecorder alloc]initwithurl:[nsurl Urlwithstring:path] settings:@{avnumberofchannelskey:@2, avsampleratekey:@44100,avlinearpcmbitdepthkey:@32,avencoderaudioqualitykey:@ (AVAudioQualityMax), avencoderbitratekey:@128000} error:&error];
/**
* Avnumberofchannelskey channel number is usually dual Channel 2
* Avsampleratekey sampling rate Hertz-"44100
* Avlinearpcmbitdepthkey Bit rate 8 16 24 32
* The quality of the avencoderaudioqualitykey sound needs to be an enumeration
Avaudioqualitymin = 0,
Avaudioqualitylow = 0x20,
Avaudioqualitymedium = 0x40,
Avaudioqualityhigh = 0x60,
Avaudioqualitymax = 0x7F
* Avencoderbitratekey audio encoded bit rate bps transfer rate 128000bps
*/
[Recorder Preparetorecord];
[Recorder record];
NSLog (@ "%@", Path);
}
Call at the end of the recording
-(void) audiorecorderdidfinishrecording: (Avaudiorecorder *) Recorder successfully: (BOOL) flag{
Where to store files
NSString *path = [Nssearchpathfordirectoriesindomains (nscachesdirectory, Nsuserdomainmask, YES) lastObject];
I'm here. The class that references the file operation
Nsfilemanager *manager = [Nsfilemanager Defaultmanager];
Get the files under all paths
Nsarray *pathlist = [manager Subpathsatpath:path];
Nsmutablearray *audiopathlist = [Nsmutablearray array];
For (NSString *audiopath in pathList) {
Differentiate between files that are needed by comparing extension names
if ([Audiopath.pathextension isequaltostring:@ "AIFF"]) {
Put the filtered files in the array
[Audiopathlist Addobject:audiopath];
}
}
NSLog (@ "%@", audiopathlist);
}
Must remember, I have learned the recording, can not learn after and did not learn the same, it is a sin ancient;;;;;;;;;
Recording of iOS development