4
我一直在努力在錄製過程中檢測到沉默。在錄製過程中檢測到沉默mac os x sdk
我在錄製和播放錄製的音頻方面很成功,但對靜音檢測一無所知。
對於錄音,我曾經使用過:https://github.com/darcyliu/CocoaSampleCode/tree/master/AVCaptureToAudioUnitOSX 它對核心音頻api有效。
任何幫助對我來說都是一個福音。
謝謝
我一直在努力在錄製過程中檢測到沉默。在錄製過程中檢測到沉默mac os x sdk
我在錄製和播放錄製的音頻方面很成功,但對靜音檢測一無所知。
對於錄音,我曾經使用過:https://github.com/darcyliu/CocoaSampleCode/tree/master/AVCaptureToAudioUnitOSX 它對核心音頻api有效。
任何幫助對我來說都是一個福音。
謝謝
您可以使用AVAudioRecorder
但是這並不是解決您的問題一個完美的方式。
NSDictionary *settings [email protected]{AVSampleRateKey:@(22050.0),
AVFormatIDKey:@(kAudioFormatLinearPCM),
AVNumberOfChannelsKey:@(1),
AVEncoderAudioQualityKey:@(AVAudioQualityMax),
AVLinearPCMBitDepthKey:@(32),
AVLinearPCMIsBigEndianKey:@(NO),
AVLinearPCMIsFloatKey:@(NO)};
AVAudioRecorder *recorder = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:@"/dev/null"] settings:setting error:nil];
[recorder prepareToRecord];
[recorder setMeteringEnabled:YES];
[recorder record];
NSTimer *levelTimer = [NSTimer scheduledTimerWithTimeInterval:0.3f target:self selector:@selector(levelTimerCallback:) userInfo:nil repeats:YES];
然後在levelTimerCallback:
方法
[recorder updateMeters];
CGFloat peak = [recorder peakPowerForChannel:0]
CGFloat average = [recorder averagePowerForChannel:0];