# Pitch detection of guitar signal

Hello,

Im doing project in which i need to find a fundamental tone of my guitar signal (something like tuner), but i just need to get a value of f0.

Firstly I have tried to do it with FFT, I was able to find freq of sinus and not complex sounds but it didnt work for guitar signal… Maybe I should improve my solution somehow ( I do FFT on signal and then i look for the bigest magnitude)

I have searched internet and found autocorrelation, YIN and some other methods. I have tried to used someone repository but I really want to do it by myself. Also tried to look for some digital sound, vst books but i couldnt find any information about it.

Maybe someone knows how can i start? Have some book with some info about it?

As you’ve discovered, just looking for the FFT bin with the largest magnitude will only work for the simplest sinusoid signals. In real instrument signals, it’s common for upper harmonics to actually have more magnitude than the fundamental, and some signals (like oboe) actually have a missing fundamental - there is no energy at the band of the fundamental frequency, but our brain perceives that as the pitch because of the pattern of harmonic overtones. That’s the trickiest case to solve.

Most autocorrelation-based methods (YIN, MPM, etc) boil down to computing some measure of correlation of the signal to itself at each possible tau offset (tau being the possible period), normalizing this data in some way, and then applying a threshold. You choose the first (smallest) tau that passes the threshold. These methods all involve the autocorrelation, energy, and some constant describing the threshold, but each method differs in the exact difference equations and normalization methods used.

Personally I started with YIN and made some modifications to improve accuracy and optimize performance. Hope this helps.

1 Like

Also note that these methods are only designed for a monophonic signal - one note at a time. You’ll need to detect the pitch of each guitar string individually (or only play one note at a time).

Okey, thank you! I ll try YIN