How do you REALLY measure THD?

With all due respect, it isn't supposed to be a test. There are only two broad classes of distortion, linear and nonlinear. There are many possible causes, especially for nonlinear distortion. Probably better not to conflate causes and effects, since the number of effects is fairly small.

However, if there were to be useful test in the context of this thread, it could be why is THD a poor metric? The answer is well-stated by Earl Geddes:

This is precisely where the signal-based distortion metrics fail. In our next paper we will show that .01%THD of one type of nonlinear system can be perceived as unacceptable while 10% THD in another example is perceived as inaudible. Even one of these simple examples is sufficient to invalidate THD as a viable metric for discussion of the perception of distortion. Furthermore, 1% THD is not at all thesame as 1% IM, but we will show that neither correlates with subjective perception.

http://www.gedlee.com/Papers/Distortion_AES_I.pdf

After a serious quest for continued support for more than a year we gave up. Our conclusion; people are satisfied with THD and IMD. It’s like the story of the cop who asks a drunk under a street light what he is doing on his hands and knee’s. The drunk replies “I’m looking for my car keys.” The officer asks “Where did you loose them?” and the drunk replies “Over there by my car.” Baffled, the officer asks “Then why are you looking for them here?” to which the drunk replies, “Because the light is better.” Everyone knows that THD is meaningless, but it’s easy todo and “the light is better.”
.
.
.
The bottom line here is that we know so little about how humans perceive the sound quality of an audio system, and in particular the loudspeaker, that one should question almost everything that we think we know about measuring it. From what we have found most of what is being done in this regard is naive.


http://www.gedlee.com/Papers/Comments on howard.pdf
 
Not really. Just that I think that discussing just one type of non ideal behaviour is a bit narrow. Margins is an implementation aspect that I dont think is a performance characteristics. But keeping the vitals in check while load is varying is of course important. The load is of course not a part of the DUT but rather a circumstance it should cope with. I would argue that FR dictates slew rate and transient (impulse / step response) basically and what we see is that slew rate might deteriorate with load variance. Noise for sure. Phase yes (i.e. time domain properties which includes GD )

So perhaps:

  • Magnitude Response (FR)
  • Distortion (unwanted new energy that was not a part of the stimuli - and not only harmonic which is seldom done)
  • Noise - which is there without stimuli.
  • Phase

.... 4!?

But these need to be describe as a function of:

  • Surrounding temperature
  • Humidity
  • Power quality
  • EMI
  • Load (reactive)
  • Duration of stimuli
  • Stimuli BW
  • ...?

//
It’s not the be all end all quality metric in amplifier design.
This was what triggered my question in the first place... sorry for going OT.

//
 
Just don't quite understand why you want to measure THD
I just don't quite understand why you need to hijack every thread that asks about THD, THD+N, and/or their measurement with your self-aggrandizing babble about how irrelevant it is as a predictor of sound quality. Please consider that science has evolved since 1938 and may have concluded something contrary to what you quote. Also please consider that some of us measure THD because it's a relevant parameter for circuit linearity.

Tom
 
  • Like
Reactions: njswede
It concerned some pretty technical details on how to measure THD, specifically in SPICE
You need to start with a transient simulation where you excite your circuit with a sine wave. You then need to set the maximum simulation step size such that you are guaranteed a simulation result for each point in the FFT, so if you're using an N-point FFT, the minimum step size needs to be (Period of Fundamental Frequency)/(N-1). So for example if you use a 1 kHz fundamental (1 ms period) and a 64k point (65536 point) FFT you need a maximum step size of 1e-3/65535 = 15.26 ns.

Then add the .FOUR (Fourier) SPICE directive to your simulation commands. Syntax: .FOUR <Freq>, where Freq is the fundamental frequency.

You can then find the THD in the SPICE output file. It usually has the extension .OUT.

Also have a look here: https://www.diyaudio.com/community/threads/thd-in-ltspice.177820/

Tom
 
Last edited:
The OP's initial question really comes in two parts. First, you have to measure THD (pretty easy these days). Second, you need to weight the harmonics such that your single number matches subjective annoyance. The second part is much more controversial. Shorter investigated weighting in the 50s and suggested n^2/4, but that gives undue weighting to inaudible harmonics. A later suggestion was CCIR468-2 weighting. Multi-tone IMD gives a really nice visual representation of what's going on, but is less easily interpreted than the "smaller is better" single number produced by a single figure THD measurement, weighted or not.

And beware that SPICE is good with BJTs, but distortion predictions with other devices are somewhere between educated and wild guesses.
 
In case of any confusion, Sean Olive and Earl Geddes didn't say what they said about THD in 1938. Not even close.
That answer does not bring me any closer to understanding why you need to hijack every thread that asks about THD/THD+N measurement with your repeated posts of that 1938 text. What are you trying to gain from that? You honestly don't put yourself in the best light with that.

Please accept that some of us like to simulate and measure THD. If this bothers you so much, just keep scrolling.

Tom
 
  • Like
Reactions: TNT
And beware that SPICE is good with BJTs, but distortion predictions with other devices are somewhere between educated and wild guesses.
It gets even more fun with some opamp models that are behavioural models. They often don't include THD, so it's easy to get -150 dB THD in SPICE. That might be useful as an indication that the circuit isn't fundamentally broken, but the THD is guaranteed to be worse in reality.

The LM3886 model provided by TI is an example of such a model.

Tom
 
  • Thank You
Reactions: EC8010
That answer does not bring me any closer to understanding why you need to hijack every thread that asks about THD/THD+N measurement...
First of all, you exaggerate how often I step up to say something. You could have saved me the trouble by saying something minimal in your own words about why some knowledgeable people warn against it. Short of anyone else choosing to be responsible, sometimes I do step up when it looks like people don't know about valid criticism of it by experts in the field. Otherwise we risk turning into another ASR where SINAD supposedly can guarantee "audible transparency." Because that's what everyone is exposed to over there. It needs to be balanced by some fact checking, although I see there is less and less of that going on in some parts of the internet.
 
Here is what Sean had to say about THD, THD+N, and SINAD that some people might rather you didn't know (especially manufacturers who hope you don't know because they sell product based on THD numbers):
No need to constantly bring up that stuff from Sean Olive. As I have already explained Sean Olive unfortunately misunderstood (or did not read) Frank Massa's article in Electronics 9/1938. THD as a single figure (like SINAD) is insufficient but THD presented as separate harmonics is ok. So FFT spectrum representation, which is included in most measurement based reviews, that shows low harmonics throughout the audio range would have been satisfactory according to Frank Massa.
 
The OP's initial question really comes in two parts. First, you have to measure THD (pretty easy these days).
You HAVE to? Wait, where's the law that says that? The main use of THD I've seen is in sales brochures (and ASR posts). Maybe we should outlaw THD. If anyone wants to start a petition, I might sign it.
Second, you need to weight the harmonics
Hold on, you've already amalgamated all the harmonic levels into a single number. Oops, I interrupted you mid-sentence.
such that your single number matches subjective annoyance. The second part is much more controversial.
Where in any THD calculation is this weighing harmonics done? Certainly not in LTspice that the OP is asking about. I ask because from what I can tell, 99.99% of the time this is NOT done.

But anyway I'll admit what you're getting at, you want to use a MODIFID method of coming up with a single number to indicate the audible effects of nonlinear distortion. This would indeed be somewhat of an improvement.

I dare say there's no sure way of weighting the harmonics to match subjective annoyance, as the harmonic distribution causes different tonalities, and different people will find some tonalities more annoying than others.

There have been attempts at weighing the harmonics differently (I suspect there's someone in this thread who can give the full history of this in excruciating detail), perhaps most notably the GedLee Metric (maybe successful technically, but not popularly). I don't see this as being controversial, other than calling it THD (which would get many persons' goats). Maybe it could be called WHT for WEIGHTED Harmonic Distortion, to distinguish it from that other thing.

I still don't like the idea of a single "annoyance number" but one thing that's widely agreed on is the first few harmonics are less annoying than the others at the same level, so if anything there should be at least two numbers, each reflecting the levels of these different harmonics. I'd be in favor of giving the level of each harmonic, measured at a certain frequency and power level. Wait, that's what LTspice is already doing for the OP.

Since I mention the GedLee Metric, here's a thread discussing it:
 
I'm a measurement guy, don't care about Spice and stuff. I usually include the harmonics that can be measured, i.e., those below the Nyquist frequency of the data acquisition. That may be rather few, depending the sampling rate. For example, with a 1 kHz fundamental and 192 kHz sampling rate, the Nyquist frequency is 96 kHz. That's sufficient for the 6th harmonic at 64 kHz (1 kHz x 2^6). With a 10 kHz fundamental, it's not possible to go higher than the 3rd harmonic (80 kHz) with 192 kHz sampling rate.

In many cases THD is dominated by the first few harmonics (2nd, 3rd), and it does not matter much if you're missing the higher order harmonics.
 
I just tried to explain in my last post that THD is a single number (with a fixed algorithm for calculating it, or at least a very few that look a lot alike such as here: https://en.wikipedia.org/wiki/Total_harmonic_distortion), and not a list of levels of harmonics.
As THD is calculated from the single harmonics the same information can be presented as a list of HD levels. Measuring harmonic distortions (and noise) is valuable but single number presentation (SINAD or THD) loses critical information which was the point of Frank Massa that Sean Olive left out.
 
  • Like
Reactions: tomchr
First of all, you exaggerate how often I step up to say something.
I do? Really? You have posted that Sean Olive screen shot at least ten times now and presented it as if it was the definitive truth. Sorry, buddy. While I respect Sean Olive's work, I cannot take a screen shot of a 1938 text seriously as scientific evidence or fact. It is an opinion. An opinion is not the same as fact or scientific evidence, even if it comes from Sean Olive.

You could have saved me the trouble by saying something minimal in your own words about why some knowledgeable people warn against it.
And why would I do that? OP states clearly that he is interested in how THD is calculated and why LTspice sometimes reports numbers that are "all over the place". There is nothing in there about the perceived sound quality or even if we are talking about an audio circuit, so why would you suddenly start talking about THD vs sound quality?

I'm not aware of any knowledgeable people who warn against the measurement or simulation of THD or THD+N any more than they warn against simulation and measurement of the frequency response. These "warnings" are a product of your imagination.

Many of us caution against relying on one single number for much of anything. That goes without saying in my opinion. But I should still be allowed to ask about how to simulate or measure a single parameter without being shouted down or having the thread hijacked, regardless of whether you find it relevant.

Otherwise we risk turning into another ASR where SINAD supposedly can guarantee "audible transparency."
We do? Really? By asking, "how do I simulate THD in LTspice and why doesn't it always give reliable results?" diyAudio will turn into a dogmatic forum where low THD is the only thing that is allowed to be discussed? The Tubes forum will be shut down. And forget about LPs, tape decks, tuners, and whatnot. Really? You think this will happen? I don't think so.

I do agree that ASR has descended into a dogmatic "dB SINAD @ 5 W per dollar" culture where circuits with higher levels of distortion are ridiculed. I'm not a fan of that. That's one of the many reasons I choose to spend my time here rather than on ASR.

You also won't find me blathering in the Tubes forum here about how low distortion is king. Why? Because I have enough self-confidence to allow others to have their opinion without having to force my opinion into the conversation. DIY audio is a hobby. If you enjoy building circuits with higher distortion because you like the sound of distortion, have at it! It doesn't hurt my feelings any.

It needs to be balanced by some fact checking, although I see there is less and less of that going on in some parts of the internet.
And you see your mindless posting of that Sean Olive screenshot as fact checking? I disagree with that. If you want to fact check, I suggest that you look at a broad range of recent papers on the subject of THD vs perceived sound quality rather than just citing one source over and over ad nauseam. AES is a good source for these papers, but there are others.

I'm an AES member and I have academic research experience. I'm happy to discuss the papers with you. Just start a separate thread on the topic and I'm happy to join you there.

Tom
 
Last edited:
  • Thank You
  • Like
Reactions: rsavas and TNT