I was trying to figure out which piano keys were being played in an audio recording using spectral analysis, and I noticed that the harmonics are not integer multiple of the base note. What is the reason for this?
Take a look at the spectrogram of a clean sample from a single piano key. I am using Piano.ff.A4 from here.
The following is the same as above, with a superimposed reference grid of $ 440 ~\mathrm{Hz}$. As you can see, the harmonics have increasingly higher frequencies than integer multiples of $440 ~\mathrm{Hz}$.
At this point you might think that the actual base frequency is just slightly higher than $440 ~\mathrm{Hz}$. So let us make a different reference grid, which lines up with the harmonic at ~$5060 ~\mathrm{Hz}$.
You can now clearly see that they aren't actually integer multiples of a base frequency.
Question: What is the explanation for this? I am looking both for simple high-level explanations of what is happening, and more in-depth, instrument specific ones, which could maybe allow me to attempt to calculate the harmonics.
My first reaction was that this must be some non-linear effect. But you can see that the harmonics do not change frequency at all as time passes and the sound gets quieter. I would expect a non-linear effect to be pronounced only in the loudest part of the sample.
Update – I measured the frequencies using peak detection on the Fourier transform from 0.3 to 0.4 seconds in the sample. This table compares the measured values with integer multiples of 440:
meas. int. mult.
440. 440.
880. 880.
1330. 1320.
1780. 1760.
2230. 2200.
2680. 2640.
3140. 3080.
3610. 3520.
4090. 3960.
4570. 4400.
5060. 4840.
5570. 5280.