TCustomSpectrumAnalyzer.THD Method

function THD: Double;

Total harmonic distortion in percent. Returns the RMS of the marked harmonic peaks (all marks after the first, when sorted by frequency, up to Harmonics) relative to the first (fundamental) marked peak.

Returns: Double - Total harmonic distortion in percent.

Remarks:

For marks sorted ascending by frequency with amplitudes A_0, A_1, ..., A_(m-1) (where m = min(Marks.Count, Harmonics)), the result is THD = 100 * (sqrt(sum_(k=1)^(m-1) A_k^2))/(| A_0 |) [%]. Domain: Amplt is a single-sided amplitude spectrum; Marks identify the fundamental (A_0) and harmonics. A pure tone (a single mark) gives exactly 0. Returns 0 when Marks.Count is 0 or on any internal error (e.g. division by a zero fundamental). The result is independent of zero padding.