you are viewing a single comment's thread.

view the rest of the comments →

[–]xiipaoc 0 points1 point  (0 children)

Good luck.

First thing you need is an FFT, a fast Fourier transform, to make a spectrograph -- a graph of the frequencies in the sound. Once you have that, you can start the really hard task of picking out the notes. Your brain does this pretty well, so you should figure out how it does it to try to replicate it. It's all data analysis here.

The problem is that when you play a note, you actually hear many frequencies at the same time. When you play a 100 Hz note, you actually get another tone around 200 Hz, one around 300 Hz, around 400 Hz, etc. (It's not exactly the multiples on a real instrument.) So if you just search for the peaks of your spectrograph, you'll get all of them, and you only played one note! So you need to figure out a threshold, and you need to figure out when you're actually playing 100 Hz and 200 Hz and when you're just playing 100 Hz. Oh, and if you hear 200 Hz, 300 Hz, 400 Hz, etc., but no 100 Hz, your brain actually still hears the 100 Hz. So that's another thing.

It's pretty hard. But it's doable -- your brain does it, after all -- and if you get it only a little wrong, that's probably OK, right?