美文网首页
录音的设置

录音的设置

作者: 码农淏 | 来源:发表于2016-12-03 16:22 被阅读53次

//录音设置

NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];

//设置录音格式  AVFormatIDKey==kAudioFormatLinearPCM

[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];

//设置录音采样率(Hz) 如:AVSampleRateKey==8000/44100/96000(影响音频的质量), 采样率必须要设为11025才能使转化成mp3格式后不会失真

[recordSetting setValue:[NSNumber numberWithFloat:11025.0] forKey:AVSampleRateKey];

//录音通道数  1 或 2 ,要转换成mp3格式必须为双通道

[recordSetting setValue:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];

//线性采样位数  8、16、24、32

[recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];

//录音的质量

[recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityHigh] forKey:AVEncoderAudioQualityKey];

// 录音创建

audioRecorder = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:path] settings:recordSetting error:&error];

// 2.准备录音

[audioRecorder prepareToRecord];



// 开启表盘,绘制分贝数

audioRecorder.meteringEnabled = YES;



[self startRecord];

相关文章

网友评论

      本文标题:录音的设置

      本文链接:https://www.haomeiwen.com/subject/ibscmttx.html