创建基于傅立叶变换的iPhone音乐Visualiser [英] Creating an iPhone music Visualiser based on Fourier Transform

查看:150
本文介绍了创建基于傅立叶变换的iPhone音乐Visualiser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iPhone设计音乐视觉化应用程序。

I am designing a music visualiser application for the iPhone.

我想通过iPhone的麦克风拾取数据,在其上运行傅里叶变换然后创建视觉效果。

I was thinking of doing this by picking up data via the iPhone's mic, running a Fourier Transform on it and then creating visualisations.

我得到的最好的例子是 aurioTuch ,它根据FFT数据生成完美的图形。但是我一直在努力在我自己的项目中理解/复制aurioTouch。

The best example I have been able to get of this is aurioTuch which produces a perfect graph based on FFT data. However I have been struggling to understand / replicate aurioTouch in my own project.

我无法理解aurioTouch在执行FFT之前从麦克风中拾取哪些数据?

I am unable to understand where exactly aurioTouch picks up the data from the microphone before it does the FFT?

还有其他任何代码的例子,我可以使用在我的项目中做到这一点吗?或任何其他提示?

Also is there any other examples of code that I could use to do this in my project? Or any other tips?

推荐答案

由于我打算自己使用麦克风的输入,我认为你的问题是一个好机会熟悉相关示例代码。

Since I am planning myself to use the input of the mic, I thought your question is a good opportunity to get familiar with a relevant sample code.

我将回溯阅读代码的步骤:

I will trace back the steps of reading through the code:


  1. SpectrumAnalysis.cpp 开始(因为很明显音频必须得到这个类),你可以看到类方法 SpectrumAnalysisProcess 有一个第二个输入参数 const int32_t * inTimeSig ---听起来有希望的起点, c>使用右键菜单项在项目中查找在此方法上,您可以看到除了明显的定义&声明,此方法仅在 FFTBufferManager :: ComputeFFT 方法中使用,其中它获取 mAudioBuffer 作为其第二个参数来自步骤1)的 inTimeSig 。寻找这个类数据成员给出多于2或3个结果,但是大多数都是只是定义/内存分配等。有趣的搜索结果是 mAudioBuffer 用作 FFTBufferManager :: GrabAudioData
  2. 中的 使用搜索选项,我们看到 FFTBufferManager :: GrabAudioData 只在一​​个名为 PerformThru 的方法内调用一次。此方法有一个名为 ioData (听起来很有希望)类型 AudioBufferList 的输入参数。
  3. 寻找 PerformThru ,我们看到它用于以下行: inputProc.inputProc = PerformThru; - 我们几乎有::看起来像注册一个回调函数。寻找 inputProc 的类型,我们确实看到它是 AURenderCallbackStruct - 就是这样。

  1. Starting off in SpectrumAnalysis.cpp (since it is obvious the audio has to get to this class somehow), you can see that the class method SpectrumAnalysisProcess has a 2nd input argument const int32_t* inTimeSig --- sounds a promising starting point, since the input time signal is what we are looking for.
  2. Using the right-click menu item Find in project on this method, you can see that except for the obvious definition & declaration, this method is used only inside the FFTBufferManager::ComputeFFT method, where it gets mAudioBuffer as its 2nd argument (the inTimeSig from step 1). Looking for this class data member gives more then 2 or 3 results, but most of them are again just definitions/memory alloc etc. The interesting search result is where mAudioBuffer is used as argument to memcopy, inside the method FFTBufferManager::GrabAudioData.
  3. Again using the search option, we see that FFTBufferManager::GrabAudioData is called only once, inside a method called PerformThru. This method has an input argument called ioData (sounds promising) of type AudioBufferList.
  4. Looking for PerformThru, we see it is used in the following line: inputProc.inputProc = PerformThru; - we're almost there:: it looks like registering a callback function. Looking for the type of inputProc, we indeed see it is AURenderCallbackStruct - that's it. The callback is called by the audio framework, who is responsible to feed it with samples.

您可能需要阅读文档 AURenderCallbackStruct (或更好, Audio Unit Hosting )以获得更深入的了解,但我希望这为您提供了一个良好的起点。

You will probably have to read the documentation for AURenderCallbackStruct (or better off, the Audio Unit Hosting) to get a deeper understanding, but I hope this gave you a good starting point.

这篇关于创建基于傅立叶变换的iPhone音乐Visualiser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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