Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone audio analysis

Tags:

iphone

I'm looking into developing an iPhone app that will potentially involve a "simple" analysis of audio it is receiving from the standard phone mic. Specifically, I am interested in the highs and lows the mic pics up, and really everything in between is irrelevant to me.

Is there an app that does this already (just so I can see what its capable of)? And where should I look to get started on such code?

Thanks for your help.

like image 384
Honus Wagner Avatar asked Jan 21 '10 14:01

Honus Wagner


People also ask

Can an iPhone measure sound frequency?

"Audio Frequency Analyzer" is a powerful real-time audio analyzer (RTA) app for iPhone. This app can measure the frequency response in 30 split band scale of 1/3 octave in real time. Also it can be displayed the FFT analysis result.

Is there a spectrum analyzer app for iPhone?

Spectrum Analyzer for iOS is a powerful real-time audio analysis app. Designed with musicians and recording engineers in mind, it can also be used by anyone interested in the world of sound. Ideal for room tuning or speaker tuning, the app enables portable, precision audio measurement and visualization.

What does Spectroid app do?

Spectroid is a real-time audio spectrum analyzer with reasonable frequency resolution across the the entire frequency spectrum.

Is there an app to measure sound frequency?

Spectrum analyser gives insight into your sounds and deconstructs the audio spectrum, showing the levels of the various frequencies in your audio signal. The built-in sound meter provides high-quality measurement results when measuring ambient noise levels in a multitude of real-life scenarios.


2 Answers

Look in the Audio Queue framework. This is what I use to get a high water mark:

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 peak power in either dB Free Scale (with kAudioQueueProperty_CurrentLevelMeterDB) or simply as a float in the interval [0.0, 1.0] (with kAudioQueueProperty_CurrentLevelMeter).

like image 170
Frank Shearar Avatar answered Sep 17 '22 23:09

Frank Shearar


Don't forget to activate level metering for AudioQueue first:

UInt32 d = 1;
OSStatus status = AudioQueueSetProperty(mQueue, kAudioQueueProperty_EnableLevelMetering, &d, sizeof(UInt32));
like image 26
Hebbian Avatar answered Sep 19 '22 23:09

Hebbian