AVAudioRecorder MAV格式录音

    //录音设置

    NSDictionary *RecordParam = [[NSDictionaryalloc] initWithObjectsAndKeys:

                                 [NSNumber numberWithFloat: 8000.0],AVSampleRateKey, //采样率

                                 [NSNumber numberWithInt: kAudioFormatLinearPCM],AVFormatIDKey,

                                 [NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,//采样位数默认 16

                                 [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,//通道的数目

                                 [NSNumber numberWithInt: AVAudioQualityMedium],AVEncoderAudioQualityKey,//音频编码质量

                                 nil];

    NSString   *DocmentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES) objectAtIndex:0];

    NSURL *url = [NSURLURLWithString:[DocmentPath stringByAppendingString:@"/luyin.wav"]];

    urlPlay = url;

    

    NSError *error;

    //初始化

    recorder = [[AVAudioRecorder alloc]initWithURL:url settings:RecordParam error:&error];

    //开启音量检测

    recorder.meteringEnabled = YES;

    recorder.delegate = self;

猜你喜欢

转载自longquan.iteye.com/blog/1925187
今日推荐