I have a recording of a single note played several times on a violin. I'm working with Matlab to estimate the amplitude of the first N harmonics. I already know which note is played but there can be fluctuations in frequency and noise (very little, actually). Can you suggest me the more robust method in this kind of situation? At the moment I am windowing the signal and using a peak detection algorithm on the FFT of each frame in order to find the amplitude of the harmonics. Is there anything better?

  • $\begingroup$ You can also try to compute the autocorrelation of the signal und looking for more than only one local maximum in the ACF. $\endgroup$
    – Vertex
    Apr 21 '15 at 10:24
  • $\begingroup$ In music processing FFT is not the best way to find the first harmonic frequency. This report discusses exactly your problem musingpaw.com/2012/04/… $\endgroup$
    – Andrea
    Nov 17 '15 at 22:01
  • $\begingroup$ Francesco, did you ever get this question answered to your satisfaction? i just now realized you're the same person asking about AMDF pitch detection. $\endgroup$ Apr 16 '16 at 4:39
  • $\begingroup$ I chose to go with ASDF, so I think this question can be considered answered $\endgroup$
    – firion
    Apr 16 '16 at 7:57
  • $\begingroup$ so now you got the pitch $\omega_0$ and you can track it. you still need to build either a heterodyne oscillator (essentially multiply your waveform $x[n]$ by $e^{jk\omega_0 n}$ and LPF to get the component at $k\omega_0$, or you need to resample each cycle (with a period of $\frac{2 \pi}{\omega_0}$ to an $N$ sample wavetable and perform an $N$-point FFT on it (the $k$th harmonic will be in $X[k]$). that's how you can get the amplitude and phase of each harmonic. $\endgroup$ Apr 16 '16 at 9:33
  1. pitch detection and tracking. use autocorrelation or perhaps AMDF (average-magnitude difference function) or ASDF (average-squared difference function).

  2. either the "heterodyne oscillator" or, i would recommend, wavetable synthesis techniques to get the amplitude and phase of each harmonic.

  • $\begingroup$ Hi, thank you for your answer. I didn't get how should I use synthesis techniques to estimate the amplitude of the harmonics. $\endgroup$
    – firion
    Apr 21 '15 at 12:38
  • $\begingroup$ if you know and track your pitch, you know the period length of each cycle in the note. you can resample each cycle (or maybe every 2nd or 3rd cycle or maybe every 10th cycle) into a buffer of N samples (maybe N being a power of 2 is good), do the FFT on that and in FFT output bins 1 and N-1 is the amplitude and phase of your 1st harmonic. bins 2 and N-2 will have your 2nd harmonic, etc. $\endgroup$ Apr 21 '15 at 19:11

If you know the precise pitch at which the note is being played, then an FFT is overkill. You can use a Goertzel filter tuned for each harmonic, with a filter length that the integer closest to an exact integer multiple of the period of the pitch. Use the same filter length for all the harmonics in order to compare their amplitudes. Most Goertzel filter formulations will give you the same result (minus numerical artifacts) as 1 bin of an FFT of the same length.

A non-rectangular window will destroy some of the amplitude information. An FFT that is of a length that is not an exact integer multiple of the period will give you scalloping errors for some or all of the harmonics, due to frequencies not being at the FFT result bin centers. A so-called "flat top" window may help, but why create errors and then try to correct them?

If you don't know the precise pitch, then you can first use a pitch estimation algorithm to estimate the frequency, and then created customized Goertzel filters to estimate the relative amplitudes of the harmonic series.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.