Thursday, 19 February 2015

THD thought experiment - Adendum


So what do we know about THD measurements?
We know that if we take a regular sine wave, clip it and compare the measurements in the frequency domain we can see how much harmonic distortion there is.
So. If this is a valid way of measuring a distortion statistic, without looking at intermodulation; we should be able to clip two or more signals which ARE NOT frequency multiples of each other, and if THD is accurate we should see a generic harmonic pattern for each fundamental with no extra noise.
Below is an image of a signal before and after clipping, at 0.5. This signal had 3 components: 1kHz, 105Hz & 6318Hz.


As you can see, that hypothesis is totally incorrect. ‘But wait’, I heard you cry, ‘You are processing in the time domain and analysing in the frequency domain’.
Below is an example of the same thing, but I have clipped the signal in the frequency domain to the same level.
The difference is, we don’t amplify signals and pass them to loudspeaker drivers in the frequency domain.
We also don’t listen to stuff being played in the frequency domain, although that is the conversion our ears do.
If you clip something in the frequency domain, you aren’t changing the numerical pattern that is the signal. You are changing the level of the harmonic components within the signal.

If you clip something in the time domain, you are literally changing the number sequence, and thus modifying the harmonic content of the signal (the sequence is just the amalgamation of infinite sinewaves, right?) literally changes the frequency content of what you are hearing more than the magnitude of the frequency content. As such, if you used a nonlinear equation that changed the probability of number values to include an even distribution of +x over a given period, you effectively add more of a frequency pattern i.e. bass spectrum stuff.  I am talking about inverse-filtering in the time domain. Kind of similar to what a vacuum tube does by being nonlinear. Exciting. 

8/10/14 - THD - Part 2



As I mentioned in the previous blog post, THD measurement allows us to see the response of a nonlinear system to a spectrally pure sine wave.
This means we can quantify, in the frequency domain how linear a system is in one dimension. This is also the flaw of THD. As we will see in later distortion analysis, the effect of distortion on a complex signal is far more variable and complex than that of a sine wave.
Below is an fft graph of a 1kHz sine wave, being clipped at a ratio of 1:2 i.e. the output of the system at the sine to (if the system was linear in response) would be a single tone at 1kHz of 0.5.

As we can see, there is harmonic content distributed at multiples of the fundamental frequency. The magnitude of the fundamental is reduced, but is still greater than the 0.5 intended limit. This is due to the fact that this is a graphical representation of the magnitude of frequency components, of a signal which has been analysed using a Fourier transform. Such is the companies between frequency domain analysis of changes that are made in the time domain. If we did a correlation between the distorted and non-distorted vector, we would be presented with a coefficient of 0.9739, which means that the change in values within the vector for a signal of roughly 23% THD, presents a 0.9739 similarity to the non-distorted signal.  
If you have ever heard something with 23% THD present, you will know that it doesn’t sound 97% similar to the non-distorted version, anecdotally. So where does this leave us? We cannot use THD to analyse complex signals, because there is inherent interaction between the frequency content a complex signal and the components caused by the nonlinear behaviour. Another angle which is not looked at In this view is the effect of phase on the signal. We need a way of looking at the effect of a nonlinear device on more than one frequency component.
We can also see that the first harmonic is dominant in this signal, and far out-weighs the energy of the following components of the signal. However, this relationship may change depending on the nonlinearity. An example of this is taking the square of the signal. This pitch-shifts the output signal, as can be seen below. Not that no other frequency components occur, and the amplitude is limited to 0.5.

It is possible to modify a nonlinear behaviour to give a pattern which is far less predictable that those shown previously, as can be seen below. This came from using the nonlinear expression (2.5*atan(0.9*x)+2.5*sqrt(1-(0.9*x).^2)-2.5) - x;
Performed on the sinewave vector x.
This is the result:



As it happens, this behaviour sounds more like a bitcrusher, where some of the other behaviours sounded rough and distorted in a more regular or recognisable pattern.

I WILL LATER ADD SOME REFERENCES TO LOOK AT

I have found a number of papers discussing methods of looking at THD in the time domain, but nothing that is either well written or seems to work.
There is another method for analysing the effect of a nonlinear device on a signal. This is Intermodulation, which I will discuss in the next post.

In the next week I am to look at ways of comparing distorted and clean signals.

Tuesday, 17 February 2015

Distortion and THD 1 – 1/10/2-14

THD 1 – 1/10/2-14

Distortion

Distortion is characterised in the Master Handbook of Acoustics (Everest & Shaw), as ‘any change in the waveform or harmonic content of an original signal, as it passes through a device. The result of nonlinearity within a device’.
This distortion not only includes having a variable input/output relationship with the signal, but may also modify the basic content of the signal.
One example of the behavioural characteristics of this nonlinearity may be the change of harmonic content within the signal with respect to the frequency domain.  There are two predominant measures of this which I will discuss briefly in the coming posts; Total Harmonic Distortion and Intermodulation Distortion. These are two methods which have been used since the 1940s, to characterise the effect a device has on a signal. There is a big catch to both of these methods, which I will also discuss.

Total Harmonic Distortion

Total harmonic distortion (THD) is the measure of a system response and viewed in the frequency domain, when the system is given an input of a spectrally pure sine wave at a given frequency (often 1kHz).
The total energy of the output (in the frequency domain) is measured, and compared with the level of the excitation tone. This relationship is characterised as a percentage, and known as the percentage of total harmonic distortion.
The benefits of this method of nonlinear behaviour characterisation, is that you can clearly see (graphically and numerically) the effect a device has on a signal. The down side is that this method by definition only works with a spectrally pure signal, and in modern measurement systems the noise floor of the system must also be taken into account. Pure sine tones do not accurately represent the complex and highly variable signals presented as music, and therefor do not relate to what realistically occurs when a system distorts musical signals. Furthermore, links to the perception of distortion of pure tones may not relate to the perception of the distortion of complex tones.
For more information: see Temme 1992 – Audio Distortion Measurements – a Brual and Kjaer text on methods of measuring distortion.
Shmilovits 2005 characterises THD in his paper ‘On the definition of Total Harmonic distortion and its effect on measurement interpretation’ as either a comparison to a signals RMS, or its harmonic content and advocates the latter. As such, I will be using this method in the analysis on the effect of the nonlinear devices.
In the following blog post, I will give an example of a total harmonic distortion measurement, and compare what is measured with a complex signal and a spectrally pure signal.

 

In the coming week I plan to try and find a method of using THD measurement to characterise the distortion effect of a device on complex music.
I will also look for supporting literature.

I have found a number of papers on the perception of distortion, but none specifically looking at the links to loudness perception. Generally most work is done on quality.