录音:
//音频会话
AVAudioSession *session = [AVAudioSession sharedInstance];
NSError *sessionError;
/*
AVAudioSessionCategoryPlayAndRecord :录制和播放
AVAudioSessionCategoryAmbient :用于非以语音为主的应用,随着静音键和屏幕关闭而静音.
AVAudioSessionCategorySoloAmbient :类似AVAudioSessionCategoryAmbient不同之处在于它会中止其它应用播放声音。
AVAudioSessionCategoryPlayback :用于以语音为主的应用,不会随着静音键和屏幕关闭而静音.可在后台播放声音
AVAudioSessionCategoryRecord :用于需要录音的应用,除了来电铃声,闹钟或日历提醒之外的其它系统声音都不会被播放,只提供单纯录音功能.
*/
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:&sessionError];
[session setActive:YES error:nil];
// 录音参数
NSDictionary *setting = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatLinearPCM], AVFormatIDKey,// 编码格式
[NSNumber numberWithFloat:8000], AVSampleRateKey, //采样率
[NSNumber numberWithInt:2], AVNumberOfChannelsKey, //通道数