简体   繁体   中英

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.

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?

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.

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.

Specifically, in the arioTouch sample, the only .mm class is the app delegate. The rest are c and C++ files (.c and .cpp). In a sense the .mm file could be your starting point for building your wrapper. The fact that is has the .mm extension simply means that it is using C++ code.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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