I'm trying to do some signal processing using an audio file (piano recordings) I find the note onsets and then perform FFT on each onset. However I find that for certain notes their 2nd harmonic has a way greater amplitude than he fundamental... Why is that??? How can I eliminate this and get the correct frequency??
1 Answers
Start by using a low-pass filter to trim out some of the higher-order harmonics. If the piano recordings that you are trying to process were recorded within a 3 octave range, that should help substantially.
Next, try adjusting your wave amplitude. Here's an article that discusses how harmonic distortion degrades a signal, and how you can exchange signal-to-noise ratio for harmonic distortion.
http://www.mathworks.com/help/signal/examples/analyzing-harmonic-distortion.html
If you want more of a home-built solution without signal filtering, here's what I'd try, assuming that the maximum signal amplitude corresponds either to the fundamental, 2nd harmonic, or 3rd harmonic 1) Find the frequency f of the maximum signal 2) If the signal at f/2 or f/3 is much greater than the noise floor, call that frequency your fundamental
Alternatively, 1) Find the frequency f of the maximum signal 2) Search above in the interval [f/2, 2*f] and find the peak nearest f. 3) Assume the difference between f and the nearest peak is 1 the fundamental frequency.
You'll need to adapt these methods to your data. Make sure your data doesn't exhibit only odd order harmonics or has very strong high-order harmonics. These methods won't work well if multiple notes are played simultaneously.
You could also try correcting your data for human ear sensitivity, as that may be the reason why the 2nd harmonics are louder on an FFT than what the ear detects relative to the fundamental. See http://en.wikipedia.org/wiki/Absolute_threshold_of_hearing