Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Pitch detection

Started by Deprogrammer Aug 28, 2008 at 10:29 PM 3 replies 9k views
Original Post
Deprogrammer
Deprogrammer
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!
PrettyBoyTim
PrettyBoyTim
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.
PrettyBoyTim
PrettyBoyTim
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.