OS X 环境中的音频文件 FFT
我希望在 OS X 上对线性 PCM 音频文件(可能具有多个音频通道)执行 FFT。解决此问题的最佳方法是什么?
多个消息来源表明 Apple 的 Accelerate Framework 正是我所需要的。如果是这样,我应该如何提取并正确准备浮点数据以供这些 FFT 函数使用?
I'm looking to perform an FFT on a linear PCM audio file (with potentially more than one audio channel) on OS X. What is the best way to go about this?
Several sources have indicated that Apple's Accelerate Framework is what I need. If so, how should I extract and properly prepare the floating point data for use in those FFT functions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这大致就是您想要做的事情。填写您自己的输入和输出函数。
希望有帮助。
Here's roughly what you want to do. Fill in your own input and output functions.
Hope that helps.
对音频数据进行 FFT 时,样本应进入实部,虚部应为零。
大多数 FFT 库(包括 Apple 的 vDSP)都包含一种称为“真实 FFT”的方法,其中输入是真实的(没有虚数分量)并且输出是复数。
When doing an FFT on audio data, the samples should go into the real portion and the imaginary portion should be zero.
Most FFT libraries, including Apple's vDSP, include a method called a "real FFT", where the input is real (no imaginary component) and the output is complex.
在我看来,您应该研究 Core Audio...我对它不是很熟悉,但看起来它应该已经为您提供了通道解交错,并且它直接与 PCM 数据一起工作。由于我不太熟悉,对此持保留态度,但我会尝试将 FFT 放入音频单元中,将单个通道的 PCM 数据作为输入,将 FFT 的结果存储在可访问的地方,然后传递输入一直到输出。
就实际执行 FFT 而言,对我来说,主要挑战似乎是将 PCM 输入强制为 FFT 例程想要操作的双 * 向量。查看 vDSP.h (加速框架的一部分),我看到像 vDSP_vflt16D (将 16 位整数向量转换为双精度实数向量)这样的函数,它看起来可以解决你的问题。
核心音频简介
It seems to me that you should be looking into Core Audio... I'm not very familiar with it, but it looks like it should get the channel deinterleaving for you already, and it works directly with PCM data. Because of my low familiarity, take this with a grain of salt, but I'd try putting the FFT in an Audio Unit, taking a single channel of PCM data as input, storing the results of the FFT somewhere accessible, and passing the input through to the output.
As far as actually performing the FFT, the main challenge seems, to me, to be in coercing the PCM input to the double * vector that the FFT routine wants to operate against. Looking through vDSP.h (part of the accelerate framework), I see functions like vDSP_vflt16D (to convert a vector of 16-bit integers to a vector of double-precision real numbers), which looks like it'd solve your problem.
Core Audio Introduction