简体   繁体   English

iPhone:objective-c中的音频分析

[英]iPhone: Audio Analysis in objective-c

I saw this post about audio analysis. 我看到了有关音频分析的帖子 Really useful, however, I hate dealing with C/C++, and looking at the apple sample code, all the extensions of the classes that use analysis in them are .mm, and syntax I'm not used to. 但是,确实非常有用,我讨厌处理C / C ++,并查看苹果示例代码,在其中使用分析的类的所有扩展都是.mm,而我不习惯使用语法。

Is there anyway to write the basic analysis code (ie getting the raw dB values) in C/C++, then create a wrapper (or some intermediate class) to make calls in objective-c, to get that value? 无论如何,有没有用C / C ++编写基本的分析代码(即获取原始dB值),然后创建包装器(或一些中间类)以在Objective-C中进行调用以获取该值?

That would be so useful if that's possible. 如果可能的话,那将非常有用。

All I basically want to do is just have a UILabel which gets updated (say 10 times a second) with the current volume in dB - once I've got that I can expand it from there myself. 我基本上只想做一个UILabel,它会以当前音量(以dB为单位)进行更新(比如说每秒更新10次)-一旦​​获得,我就可以从那里扩展它。

It is possible, for sure. 当然有可能。

You need first to decide how your Objective C wrapper looks like (ie, what functionality it "exports" from the C++ portion) and the implement it by instantiating objects and calling methods in the C++ layer. 您首先需要确定Objective C包装的外观(即,它从C ++部分“导出”的功能),并通过实例化对象和在C ++层中调用方法来实现它。

Specifically, in the arioTouch sample, the only .mm class is the app delegate. 具体来说,在arioTouch示例中,唯一的.mm类是应用程序委托。 The rest are c and C++ files (.c and .cpp). 其余的是c和C ++文件(.c和.cpp)。 In a sense the .mm file could be your starting point for building your wrapper. 从某种意义上说,.mm文件可能是构建包装器的起点。 The fact that is has the .mm extension simply means that it is using C++ code. 具有.mm扩展名的事实仅表示它正在使用C ++代码。

I think that if you remove from the app delegate all that has to do with the application delegate protocol and with the OpenGL representation, you will automagically obtain your wrapper. 我认为,如果您从应用程序委托中删除所有与应用程序委托协议和OpenGL表示形式有关的内容,那么您将自动获取包装器。

Besides that, you should identify the fft part in applicationDidFinishLaunching and put it in a method that will be the main entry point of your wrapper. 除此之外,您应该在applicationDidFinishLaunching标识fft部分,并将其放在将成为包装器主要入口点的方法中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM