IPhone Audio Analysis

I am developing an application for the iPhone, which will potentially include a “simple” analysis of the sound received from the standard microphone of the phone. In particular, I am interested in the maximums and minimums of microphones, and really everything in between is not related to me.

Is there an application that does this already (just so I can see what it is capable of)? And where should I start working on such code?

Thank you for your help.

+7
iphone
source share
4 answers

See Audio Queue Structure . This is what I use to get the high water sign:

AudioQueueRef audioQueue; // Imagine this is correctly set up UInt32 dataSize = sizeof(AudioQueueLevelMeterState) * recordFormat.mChannelsPerFrame; AudioQueueLevelMeterState *levels = (AudioQueueLevelMeterState*)malloc(dataSize); float channelAvg = 0; OSStatus rc = AudioQueueGetProperty(audioQueue, kAudioQueueProperty_CurrentLevelMeter, levels, &dataSize); if (rc) { NSLog(@"AudioQueueGetProperty(CurrentLevelMeter) returned %@", rc); } else { for (int i = 0; i < recordFormat.mChannelsPerFrame; i++) { channelAvg += levels[i].mPeakPower; } } free(levels); // This works because one channel always has an mAveragePower of 0. return channelAvg; 

You can get maximum power either in dB Free Scale (with kAudioQueueProperty_CurrentLevelMeterDB), or just as a float in the interval [0.0, 1.0] (with kAudioQueueProperty_CurrentLevelMeter).

+9
source share

Remember to first activate level measurement for AudioQueue:

 UInt32 d = 1; OSStatus status = AudioQueueSetProperty(mQueue, kAudioQueueProperty_EnableLevelMetering, &d, sizeof(UInt32)); 
+4
source share

Check out the "SpeakHere" code example. it will show you how to record audio using the AudioQueue API. It also contains some real-time sound analysis code to show a level indicator.

In fact, you can use most of this level meter code to answer "highs" and "lows."

+2
source share

Sample Code AurioTouch performs Fourier analysis at the microphone input. May be a good starting point:

https://developer.apple.com/iPhone/library/samplecode/aurioTouch/index.html

Probably redundant for your application.

0
source share

All Articles