1

iPhoneで振動を検出することはできますか?電話が机やテーブルの上に置かれているときに、ユーザーが机やテーブルを叩いたことを検出する方法を見つけようとしています。マイクと AVFoundation を使って木製のテーブルを叩く音を検出できるという記事をどこかで読んだことを覚えています。何か案は?

ありがとう

4

1 に答える 1

0

マイクのルートをたどると、次のような方法でうまくいく可能性があります。

//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];
} 
于 2011-03-23T23:48:14.873 に答える