但我不能受到打击.我有声音
NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithfloat: 44100.0],AVSampleRateKey,[NSNumber numberWithInt: kAudioFormatAppleLossless],AVFormatIDKey,[NSNumber numberWithInt: 1],AVNumberOfChannelsKey,[NSNumber numberWithInt: AVAudioQualityMax],AVEncoderAudioQualityKey,nil];NSError *error;recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];if (recorder) { [recorder preparetoRecord]; recorder.meteringEnabled = YES; [recorder record]; levelTimer = [NSTimer scheduledTimerWithTimeInterval: 0.3 target: self selector: @selector(levelTimerCallback:) userInfo: nil repeats: YES];} else NSLog(@"error %@",[error description]);
但声音没有打击.
解决方法 你必须要玩低通结果.试试这个:- (voID)levelTimerCallback:(NSTimer *)timer { [recorder updateMeters]; const double Alpha = 0.05; double peakPowerForChannel = pow(10,(0.05 * [recorder peakPowerForChannel:0])); lowPassResults = Alpha * peakPowerForChannel + (1.0 - Alpha) * lowPassResults; //NSLog(@"%f",lowPassResults); if (lowPassResults > 0.55) NSLog(@"Mic blow detected");}总结
以上是内存溢出为你收集整理的如何在iphone中检测来自麦克风而不是语音的打击?全部内容,希望文章能够帮你解决如何在iphone中检测来自麦克风而不是语音的打击?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)