Pitch detection

Started by
3 comments, last by PrettyBoyTim 15 years, 7 months ago
Hello, I would like to make a real-time pitch detection application. Nothing fancy, just a console app. Ideally, the user would generate a sound, through mic or another input device, and using the fast Fourier transform (FFT), or something similar, the pitch would be determined from the raw audio stream, and then it would be displayed. Although I understand the gist of how it works, I have no idea where to begin in terms of code. Can someone help me out and set me on the right path? Thanks in advance!
Advertisement
Perhaps you can find some FFT code on programmers heaven. Perhaps this code you can learn from.
You can get code and explanation for the FFT in the on line book numerical recipes
If instead you're looking for a free library, then of course FFTW is what you want.
I've done a bit of work with pitch detection, and I found that I got the best results using a system called 'Enhanced Autocorrelation'.

First, look up Autocorrelation. I found this link to be pretty useful in understanding the algorithm:

http://cnx.org/content/m11714/latest/

'Enhanced Autocorrelation' is described in a paper by Tolonen and Karjalainen, but you have to pay for it, so I'll describe the basic idea here:

1: Run a normal autocorrelation over the signal
2: Clip all results that are below zero
3: Results should be stretched by a factor of two and subtracted from original signal
4: Clip all results below zero


After that there are various methods you can use to pick the most likely frequency, but the simplest is just to pick the one with the highest value in the results.
Oh, I should also mention that they've implemented Enhanced Autocorrelation (EAC) in Audacity, so you can just have a look at their source code if you need some more pointers, or if you need to compare your results with some code that is known to work.

This topic is closed to new replies.

Advertisement