Electronic – use the FFT to recognize musical notes on a piano

fouriersignal processing

I want to create a tool which recognizes a few musical notes (I know this is re-inventing the wheel). So I would play middle C, D, and E on a piano and it should be able to classify those notes. Here's how I think I should approach it:

  1. Record a sample of me playing a note
  2. Convert the signal to the frequency domain using the fast fourier transform
  3. Find the frequency that is most present (basically argmax of the frequency domain data)
  4. Assume that frequency comes from the note played and use that to classify the note

I haven't tried any of this yet because I don't want to start down the wrong path. So, theoretically, will this work?

Best Answer

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.

Related Topic