开发者

Detecting Vibration on a Table with the iPhone

is it possible to d开发者_如何转开发etect vibration on the iPhone? I'm trying to figure out how to detect when the user smacks a desk or table when the phone is sitting on it. I remember reading somewhere you could detect a smack on a wooden table using the mic and AVFoundation. Any ideas?

Thanks


if you go down the microphone route, something like this might do the trick:

//somewhere during setup call this line
[anAVAudioRecorder setMeteringEnabled:YES];

//then in a method used to poll the audioMeter
[anAVAudioRecorder updateMeters];
averagePower = [anAVAudioRecorder averagePowerForChannel:0];
if (averagePower > threshold ) {
    [musicPlayerClass play];
} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜