iPhone 上的频率检测
我目前正在开发的应用程序的一部分将用作调谐器。我希望能够使用 iPhone 显示用户给出的信号的峰值频率。我使用了 SCListener,它在 iPhone 模拟器上运行得非常好。然而,当我在真实设备上尝试时,却没有。
论坛建议我使用苹果 FFT 和加速框架来做到这一点,但它似乎过于复杂。如果任何编写过调谐器或类似程序的人能给我指出一个好的方向,我将非常感激!
谢谢!
One part of an app I'm currently working on will work as a tuner. I want to be able to use the iPhone to display the peak frequency of a signal given by the user. I have used the SCListener which worked very good on the iPhone simulator. However when I tried it on a real device it didn't.
Forums suggests that I use apple FFT and accelerate Framework to do this but it seems overly complicated. I would really appreciate if anyone that has programmed a tuner or similar could point me in a good direction!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 dsp.stackexchange 上有一个相关帖子。这表明,如果基波的幅度低于谐波,自相关在寻找基波方面会比 FFT 更好。自相关比 FFT 稍微简单一些。加速框架将再次为您提供帮助。然而,通常情况并非如此。
我不知道有什么现成的解决方案可以为您完成所有工作。 vDSP 编程指南有 真实的具体工作示例您可能想研究一下 FFT,需要一些时间来适应,但确实值得。恐怕 FFT 似乎是峰值频率提取中最合乎逻辑的第一步。大多数消息来源似乎还表明,在运行 FFT 之前对时域信号应用加窗函数至关重要(否则,由于末端的不连续性,您将得到高频伪影)。
另外,您可能想查看 此相关 SO发布。
There is a related post on dsp.stackexchange. It suggests that autocorrelation will work better than FFT at finding the fundamental, if the fundamental is lower in amplitude than the harmonics. Autocorrelation is slightly less tricky than FFT. The accelerate framework will come to your help there again for that. However this is not the case usually.
I don't know of any out of the box solutions which will do all the work for you. The vDSP Programming Guide has specific worked examples for real FFTs which you might want to look into, it takes some getting used to, but it's worth it really. FFT seems like the most logical first step in peak frequency extraction I'm afraid. Most sources seem also to suggest that applying a windowing function to the time domain signal before running the FFT is critical (or you will get high frequency artifacts because of discontinuities at the extremities).
Also you might want to check out this related SO post.
峰值频率通常与(音乐)调谐器估计的音调频率不同。查找音高估计。
Peak frequency is often different from the pitch frequency that one would want a (music) tuner to estimate. Look up pitch estimation.
从以前的经验来看:
希望有所帮助。
From previous experience doing this :
Hope that helps.
感谢所有的答案!我在代码中遗漏了使 SC 侦听器也能在设备上工作的部分,但现在正尝试针对 Apple 自己的 AVAudioRecorder 进行更改,因为它应该要快得多。问题是 cocos2d 框架阻止了声音的录制,直到您调用允许此操作的方法。现在它就像一个魅力! :)
再次感谢!
Thanks for all the answers! I had missed a part in my code to make the SC listener work on the device as well but are now trying to change it for Apples own AVAudioRecorder since it is suppose to be a lot faster. The problem was that the cocos2d framework blocked the recording of sounds until you called for a method that allowed this. It works like a charm now! :)
Thanks again!