5
我使用此代码来检测打击。如何在iPhone中检测麦克风不响的声音?
但我无法得到的打击。我有声音。
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]);
但得到了声音不吹。
是的,它吹,不是吗? (如果你解释了你的意思,可能会更好一些。) –
(你在那里做的只是启动一个录音机,这不会,自己买,检测任何东西。) –
最后,我得到了它,感谢每一个 – jpd