理解FFT在aurioTouch2 [英] Understanding FFT in aurioTouch2

查看:371
本文介绍了理解FFT在aurioTouch2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从苹果的样品code看着aurioTouch 2(<一个href=\"http://developer.apple.com/library/ios/#sample$c$c/aurioTouch2/Listings/Classes_aurioTouchAppDelegate_mm.html#//apple_ref/doc/uid/DTS40011369-Classes_aurioTouchAppDelegate_mm-DontLinkElementID_6\">found这里)。在一天结束时,我要分析的频率自己。现在我想明白了一些东西是怎么回事的。我的道歉,如果这是小事,只是想了解一些注释掉幻数漂浮在某些来源的。我困惑的要点,现在是:


  1. 为什么他们零出在FFTBufferManager :: ComputeFFT奈奎斯特价值?可以将此值真的只是被扔掉? (〜FFTBufferManager.cpp线112)。

  2. 他们都规模下降-128db,所以我假设的结果是这样的范围(-128,0)。然而,在后来aurioTouchAppDelegate.mm(〜行807),他们将其转换为0和1之间的值加上80和除以64,然后夹持到0和1为什么模糊?另外,我说的对的假设值将在(-128,0)?
  3. 附近

解决方案

好吧,这不是小事,我不是,但我是这样理解的。如果我在简化纯粹是为我好,我的意思并不是要光顾。

归零对应奈奎斯特频率的结果:

我要假设我们正在计算1024输入样本的正向FFT。在44100hz输入这通常是真实的在我的情况(但不是什么AurioTouch在做,我觉得这有点不可思议,但我不是专家)。这容易,我用具体数值理解。

鉴于1024(n)的输入采样,根据需要(偶数索引'第一然后奇数索引{在[0],在[2],[4],...,在<一布置href=\"http://developer.apple.com/library/ios/#documentation/Performance/Conceptual/vDSP_Programming_Guide/UsingFourierTransforms/UsingFourierTransforms.html\">1, [3],[5],...})(使用 vDSP_ctoz()来订购您的输入)

FFT的输出 1024 (n)的输入样本为 513 ((N / 2)+1)复杂的值。即 513实组件和 513假想的组件,总共 1026 的值。

然而,假想[0] 假想[512] (N / 2)总是必然,。因此将真正的[512] (奈奎斯特频率仓的实部)在假想[0] 并遗忘假想[512] - 这始终是零,并且可以推断,结果被打包成一个的 1024 (n)的长度的缓冲区。

因此​​,返回的结果是有效的,你必须至少将虚[0] 返回到零。如果你要求所有的 513 ((N / 2)+1)的频率段,你需要另外一个复杂的价值附加到的结果,并将其设置这样..

  unpackedVal =虚[0]
真正的[512] = unpackedVal,虚[512] = 0
假想[0] = 0

在AurioTouch我一直认为他们只是不打扰。 N / 2的结果显然更为方便,工作,你也很难从展示台告诉: - 哦,看,它缺少一个数量级在奈奎斯特频率

<一个href=\"http://developer.apple.com/library/ios/#documentation/Performance/Conceptual/vDSP_Programming_Guide/UsingFourierTransforms/UsingFourierTransforms.html\">The UsingFourierTransforms文档说明包装

NB的具体数值1024,513,512等都是例子不是n的实际值,(N / 2)+1,正从AurioTouch / 2。

他们都规模下降-128db

不太,输出值的范围是相对于输入样本的数目的,以便它可以规格化。规模为1.0 /(2 * inNumberFrames)。

在比例范围为 -1.0 - > +1.0 。然后复矢量的幅度被取(相位被忽略)给出标量值之间的每个频率仓的 0和1.0

此值则作为PTED -128和0之间的分贝值间$ P $

图纸的东西... + 80/64 ...... * 120 ......我不知道。我可能是完全错误的,也可以是......艺术照?

I've been looking at aurioTouch 2 from Apple' sample code (found here). At the end of the day I want to analyze the frequencies myself. For now I'm trying to understand some of what's going on here. My apologies if this is trivial, just trying to understand some of the uncommented magic numbers floating around in some of the source. My main points of confusion right now are:

  1. Why do they zero out the nyquist value in FFTBufferManager::ComputeFFT? Can this value really just be thrown away? (~line 112 of FFTBufferManager.cpp).
  2. They scale everything down by -128db, so I'm assuming that the results are thus in the range of (-128, 0). However, later in aurioTouchAppDelegate.mm (~line 807), They convert this to a value between 0 and 1 by adding 80 and dividing by 64, then clamping to 0 and 1. Why the fuzziness? Also, am I right in assuming values will be in the vicinity of (-128, 0)?

解决方案

Well, it's not trivial for me either but this is how i understand it. If i've over simplified it is purely for my benefit, i don't mean to be patronising.

Zeroing the result corresponding to the Nyquist frequency:

I'm going to suppose we are computing the forward FFT of 1024 input samples. At 44100hz input this is usually true in my case (but isn't what AurioTouch is doing, which i find a bit weird, but i'm no expert). It's easier for me to understand with specific values.

Given 1024 (n) input samples, arranged as needed (even indexes' first then odd indexes' { in[0], in[2], in[4], …, in1, in[3], in[5], … }) (use vDSP_ctoz() to order your input)

The output of FFT 1024 (n) input samples is 513 ((n/2)+1) complex values. ie 513 real components and 513 imaginary components, a total of 1026 values.

However, imaginary[0] and imaginary[512] (n/2) are always, necessarily, zero. So by placing real[512] (the real component of the Nyquist frequency bin) at imaginary[0] and forgetting imaginary[512] - which is always zero and can be inferred, the results are packed into an 1024 (n) length buffer.

So, for the returned results to be valid you must at least set imaginary[0] back to zero. If you require all 513 ((n/2)+1) frequency bins you need to append another complex value to the result and set it thus..

unpackedVal = imaginary[0]
real[512]=unpackedVal, imaginary[512]=0
imaginary[0] = 0

In AurioTouch i always supposed they just don't bother. n/2 results is obviously more convenient to work with and you can hardly tell from the visualizer:- "Oh look, it's missing one magnitude at the Nyquist frequency"

The UsingFourierTransforms docs explain the packing

NB the specific values 1024, 513, 512, etc. are examples not the actual values of n, (n/2)+1, n/2 from AurioTouch.

They scale everything down by -128db

Not quite, the range of the output values is relative to the number of input samples so it has to be normalised. The scale is 1.0/(2*inNumberFrames).

After scaling the range is -1.0 –> +1.0. The magnitude of the complex vector is then taken (the phase is ignored) giving a Scalar value for each frequency bin between 0 and 1.0

This value is then interpreted as a decibel value between -128 and 0

The drawing stuff… +80 / 64. …*120… …i'm not sure. I may be completely wrong or it may be …artistic license?

这篇关于理解FFT在aurioTouch2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆