Calculating THD where peaks are not exact harmonics I have captured an FFT of a 1 kHz signal that I am generating using a WM8904 codec running at 48k samples/second connected via I2S to a ARM microcontroller (Atmel SAME70).  It appears to have some jitter in it, which I believe is due to a small delay in restarting the DMA after each block (which I know how to fix, but I was more interested at this point in the particulars of taking this measurement).  I am using a Agilent MSO7054B to make the measurements.



The fundatmental is clearly visible at 1.0 kHz.  But the next peak is at 2.1 kHz, not 2.0; the one after that at 3.2 kHz, etc.  Is that due to the jitter?

Can I still use those peaks to calculate a THD value?  When doing so, I got a value of 4.12%.  Does that seem reasonable?
Jitter should pretty much be zero-mean, otherwise it'd be a frequency offset.

I've zoomed into your screenshot and it seems the horizontal distance between two points in the FFT plot is about 5 pixels, and your picture happens to be 1000 pixel wide – wild guess, this is an 256-point FFT.

In that case, the frequency bin spacing is $\frac{f_{sample}}{256}=\frac{111\,\text{kHz}}{256}\approx433.6\,\text{Hz}$; that explains why you see an "unsharp" peak for your fundamental, and why your harmonics don't happen to land in exact multiples of where you presume they should be. (The wide peak is just leakage in action – oscillations that don't fit in one DFT window of observation leak energy in multiple DFT bins.)

Either, use a signal frequency that is a multiple of the resolution calculated above, or change the sampling rate or DFT length. Simple as that: make your oscillation fit an integer time in the 256 sample points that your DFT is long.

Generally, you'll get finer frequency bin spacing and a more accurate PSD estimate with larger DFT sizes – so, if your scope allows you to somehow export a couple thousand points to your PC, just do the frequency analysis there; it's really not that hard using python these days :)