Can I use the FFT to recognize musical notes on a piano?

The concept is good, but you will find it is not so simple in practice.

Pitch is not simply the predominant tone, so there's problem number 1.

The FFT frequency bins can't hit all (or even multiple) tones of the musical scale simultaneously.

I would suggest playing with an audio program (for example, Audacity) that includes an FFT analyser and tone generator to get a feel for what it can (and can't) do before you try to implement a particular task using the FFT.

If you need to detect just a few specific tones, you may find the Goertzel algorithm to be easier and faster.

Pitch detection is complicated, and there is still research going on in that field. Tone detection is pretty straight forward, but may not get you what you want.


I would say using a multimodal observation window of the signal would be better. Something along the lines of a wavelet decomposition of your audio signal which will allow you to identify the multiple overtones inside the note. Yup, actually Wavelets, I would say is the way to go.

This is a very generalised breakdown of what wavelets are, but think of them as a multiresolution window that passes over your signal like a STFT. So you can identify different sinusoidals which occur at different temporal locations within your signal. this is also important as the note you play is not a stationary signal, it plays and then decays over time. I am not a musician, however I believe that tone dominence changes throughout the decay of the note.

of course after the wavelet decomposition wou will need to implement algorithms that identify notes and peripheral tones.

I think wavelets really address the problems people have been talkaning ybout in terms of pitch identification.

if you would like to learn how wavelets work this is a wonderful whitepaper released by HP about it :) http://www.hpl.hp.com/hpjournal/94dec/dec94a6.pdf and Introduction to Wavelets

for implementation, MATLAB has a wavelet tool and I am sure there is a plethora of other packages available for platforms like R, etc.