Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bbass408

macrumors newbie
Original poster
Mar 19, 2011
2
0
I'm a ultra noob both to IOS/Cocoa programming and this forum.

I'm designing an app that detects the pitch of a note a user is "singing" into the mic and i want to compare it to reference and tell them how accurate they are. It's like a guitar tuner app which I see being sold.

How do I get the pitch of a note coming into the input?

I see lots of reference on how to get the amplitude. I wonder if they even provisioned for simple pitch (or average pitch) detection in the SDK. Perhaps I'm oversimplifying and I need to do some complicated DSP to figure that out.

In general, I understand code. But, new to objective C so bear with me.

Any help or advice would be gratefully appreciated.
 
I see lots of reference on how to get the amplitude. I wonder if they even provisioned for simple pitch (or average pitch) detection in the SDK. Perhaps I'm oversimplifying and I need to do some complicated DSP to figure that out.
It's DSP but should not be that complicated.

Basically your audio waveform is amplitude vs. time and you want to transform that into amplitude vs. frequency. That little bit of DSP is called a Fourier transform and is usually implemented with a Fast Fourier Transform (FFT) routine.

Here's a link to a discussion about FFT on the iPhone. http://oscopeapp.com/opensource-fft-for-the-iphone and Apple's own FFT from the current SDK http://developer.apple.com/library/ios/#documentation/Performance/Conceptual/vDSP_Programming_Guide

Once you have amplitude vs. frequency, you can pick off the dominant frequency and convert it to pitch.

B
 
You will need some complicated DSP code.

Ignore the suggestion to just use an FFT, as most real world musical notes throw off mostly overtone frequencies that are very different from the pitch class of the actual musical note. FFTs also have time vs. resolution quantization problems.

Look up autocorrelation, MACF, AMDF, cepstrum or cepstral analysis, harmonic product spectrum, RAPT, YIN, et.al. It appears to still be an on-going research topic.

For audio input on an iOS device, you will also need to know how to use the Audio Queue or Audio Unit RemoteIO APIs, which are non-trivial to configure.

It is possible, as there appear to many apps (over a hundred) in the App store claiming to detect pitch, a small number of which almost work decently.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.