AVAudio 检测音符/音调/等。 iPhone xcode 目标-c
我正在 iPhone 上制作一个应用程序,我需要一种方法来检测通过麦克风传入的声音的音调。 (即 A#、G、C♭ 等) 我以为我会使用 AVAudio 但我真的不知道,而且我在文档中找不到任何内容..
有什么帮助吗?
I'm making an app on the iphone and I need a way of detecting the tune of the sounds coming in through the microphone. (I.e. A#, G, C♭, etc.)
I assumed I'd use AVAudio but I really don't know and I can't find anything in the documentation..
Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
音符只不过是声音的特定频率。您将需要一种方法来分析输入信号中的所有频率,然后找到一种方法来隔离各个音符。
使用快速傅里叶变换 (FFT) 查找音频信号中的频率。网上有大量源代码可用于根据音频信号计算 FFT。特别是,oScope 为 iPhone 提供了开源解决方案。
编辑: 音调检测似乎是您想要做的事情的技术名称。此处类似问题的答案可能是有用的。
Musical notes are nothing more than specific frequencies of sound. You will need a way to analyze all of the frequencies in your input signal, and then find a way to isolate the individual notes.
Finding frequencies in an audio signal is done using the Fast Fourier Transform (FFT). There is plenty of source code available online to compute the FFT from an audio signal. In particular, oScope offers an open-source solution for the iPhone.
Edit: Pitch detection seems to be the technical name for what you are trying to do. The answers to a similar question here on SO may be of use.
iOS API 中没有内置任何用于音高估计的内容。您必须编写自己的 DSP 函数。 Accelerate 框架中的 FFT 将为您提供来自 PCM 采样波形的频谱频率信息,但频率与心理感知音调不同。
估计频率和音调的方法有很多好坏。我的 DSP 资源网页 上有各种估算方法的长长的部分列表。
您可以查看 Apple 的 aurioTouch 示例应用程序,了解获取 iOS 设备音频输入并显示其频谱的示例。
There's nothing built-in to the iOS APIs for musical pitch estimation. You will have to code your own DSP function. The FFTs in the Accelerate framework will give you spectral frequency information from a PCM sampled waveform, but frequency is different from psycho-perceptual pitch.
There are a bunch of good and bad ways to estimate frequency and pitch. I have a long partial list of various estimation methods on my DSP resources web page.
You can look at Apple's aurioTouch sample app for an example of getting iOS device audio input and displaying it's frequency spectrum.
就像 @e.James 所说,您正在寻找音符的音高,这称为音高检测。斯坦福大学 CCRMA 有大量资源可以满足您的需求。只是google 进行音调检测,您会看到一系列出色的算法。至于想要查找音频样本块的 FFT,您可以使用 Accelerate Framework 的内置 FFT 函数(请参阅 这个 和 这个)或使用MoMu 工具包。使用 MoMu 的好处是它的功能可以将音频流分解为样本,并且可以使用它自己的功能轻松应用 FFT。
Like @e.James said, you are looking to find the pitch of a note, its called Pitch Detection. There are a ton of resources at CCRMA, Stanford University for what you are looking for. Just google for Pitch Detection and you will see a brilliant collection of algorithms. As far as wanting to find the FFT of blocks of Audio Samples, you could use the built-in FFT function of the Accelerate Framework (see this and this) or use the MoMu toolkit. Using MoMu has the benefit of it's functions decomposing the audio stream into samples for you and easy application of the FFT using it's own functions.