iPhone 上的频率检测

发布于 2024-12-18 18:07:15 字数 281 浏览 2 评论 0原文

我目前正在开发的应用程序的一部分将用作调谐器。我希望能够使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

菩提树下叶撕阳。 2024-12-25 18:07:15

在 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.

别念他 2024-12-25 18:07:15

峰值频率通常与(音乐)调谐器估计的音调频率不同。查找音高估计。

Peak frequency is often different from the pitch frequency that one would want a (music) tuner to estimate. Look up pitch estimation.

萌酱 2024-12-25 18:07:15

从以前的经验来看:

  1. FFT 并不总是像您想象的那么准确,并且计算量大
  2. 自相关给出了相当好的结果
  3. 如果您有很强的基础,零交叉可以非常准确并且计算效率很高(只需计算一段时间内信号过零的次数,f =(2 x 时间段(以秒为单位))/(过零次数)\

希望有所帮助。

From previous experience doing this :

  1. FFT isn't as always as accurate as you might think, and is computationally expensive
  2. Autocorrelation gives pretty good results
  3. If you have a strong fundamental, zero-crossing can be very accurate and is very computationally efficient (just count the number of times the signal crosses zero over a period of time, f = (2 x time period in seconds)/(number of zero crossings)\

Hope that helps.

绅刃 2024-12-25 18:07:15

感谢所有的答案!我在代码中遗漏了使 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文