iphone - 检测到对 iPhone 麦克风的吹气吗?

标签 iphone

我正在尝试检测用户何时向 iPhone 的麦克风吹气。现在我正在使用 Stephen Celis 中的 SCListener 类打电话

if ([[SCListener sharedListener] peakPower] > 0.99)

在 NSTimer 中。然而,有时当我不吹气时,这又会出现。有人有任何示例代码来检查用户是否对着麦克风吹气吗?

最佳答案

我会推荐low-pass filtering首先是电源信号。总会有一定量的 transient 噪声会干扰瞬时读数;低通滤波有助于缓解这种情况。一个漂亮且简单的低通滤波器将是这样的:

// Make this a global variable, or a member of your class:
double micPower = 0.0;
// Tweak this value to your liking (must be between 0 and 1)
const double ALPHA = 0.05;

// Do this every 'tick' of your application (e.g. every 1/30 of a second)
double instantaneousPower = [[SCListener sharedListener] peakPower];

// This is the key line in computing the low-pass filtered value
micPower = ALPHA * instantaneousPower + (1.0 - ALPHA) * micPower;

if(micPower > THRESHOLD)  // 0.99, in your example
    // User is blowing on the microphone

关于iphone - 检测到对 iPhone 麦克风的吹气吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/795968/

相关文章:

iphone - 导航栏中的信息灯按钮

iphone - 使用贝塞尔曲线路径自定义裁剪图像

iphone - 如何让我的表格 View 进入编辑模式?

iphone - 在 iOS 应用程序 : audio but no picture 中播放视频

ios - UICollectionReusableView 中的标签仅在偶数索引中显示

iPhone 应用商店本地化

iphone - 如何创建 Facebook-App 风格的通知自定义表格?

iOS FB graph api 大规模访问相册图片

ios - Storyboard中的隐形图像

iphone - 如何保存应用程序的当前状态