Harmonic distortion

Introduction

The purpose of harmonic distortion is to generate new partials from an existing audio signal and add those partials to the original sound. If these partials are harmonic to the partials in the original sound they will blend with the original sound and subtly change the timbre. The effect of harmonic distortion is different to the effect of filters, as filters tend to take away and emphasize existing aspects of a sound while harmonic distortion can create and add new aspects to a sound. All analogue circuitry does to some extent exhibit harmonic distortion, but most circuitry, e.g. HiFi amplifiers, are designed to generate as little harmonic distortion as possible to get a faithful reproduction of the original signal. In the digital domain, after a signal is digitized by an analog to digital converter, the computer code instructions that act on the stream of numbers representing the sound do not add any harmonic distortion, simply as the operations initiated by the instructions are strictly linear.

The amount of harmonic distortion is expressed as THD (Total Harmonic Distortion). THD is measured by subtracting the original input sound from the distorted sound in a way that a signal with only the distortion is generated. Then the average energy of the distortion is compared with the average energy of the original sound and this ratio is expressed as a percentage. When the THD of an amplifier is below 0.1% THD it is considered to be HiFi. Below this value the amount of THD is hardly noticed by the average listener. When distortion is wanted for musical purposes the THD is exaggerated by design to figures that might go way up to 30%, which results in a severely distorted sound. But the THD value doesn't say much about the sonic effect, as it does not specify which harmonics are generated and in which range of the audio spectrum. So, two harmonic distortion devices from different manufacturers can both have a measured THD of 30% but still sound completely different. E.g. one may have a muffled grungy effect, while the other might add a bright fuzzy edge to a sound.

When a monophonic single pitched sound is distorted using harmonic distortion, either only odd harmonics or a mix of odd and even harmonics will be added to the sound. These odd and/or even harmonics are created from every partial present in the original sound. When instead of a single pitched sound a chord is distorted, an extra effect can be noticed which is caused by intermodulation of the harmonics that are generated from the different pitches in the chord. This effect is named intermodulation distortion or IMD. These extra partials might be harmonic or enharmonic and can have pitches below the lowest pitch in the chord. When such a low-pitched partial is harmonic to one of the pitches in the chord it is commonly named a subharmonic. These subharmonics will add a grungy bottom under the chord. Tuning becomes essential here; a just tuning will sound better as an equal temperament tuning. The faster beating in the equally tempered chords will be strongly exaggerated by the harmonic distortion, which sounds uneven and in general not very good. In contrast, the very slow beating in just tuned chords will enhance the effect of tension in the sound, giving a sense that the sound is going somewhere. IMD also points to the new partials created from the partials already created by the distortion, most of these will be enharmonic. Because of the possible enharmonic products of harmonic distortion designers of recording and mixing equipment consider harmonic distortion a little devil that must be fought fiercely. Rock musicians on the other hand discovered that harmonic distortion boosts the impact of e.g. the rock guitar sound tremendously, and deep harmonic distortion is sort of the trademark of styles like heavy metal. Another early example of use of harmonic distortion is the heavily overdriven Hammond organ sound, often combined with Leslie speaker cabinets, as used in the psychedelic music of the late sixties in the twentieth century.

Analogue distortion devices make use of nonlinear properties, e.g. saturation effects, in a suitable component to create a distortion effect. An example is a property that when a voltage over the component is increased the component's electrical resistance will gradually decrease. When such a component is used in an amplification circuit it can result in a transfer curve where a higher input voltage value will be amplified less than a lower input voltage. Examples of suitable components that exhibit this behaviour are the germanium diode and analogue VCA circuits based on OTA chips (Operation Transconductance Amplifier). These OTA chips can have a THD percentage that can be around 10%. Magnetic recording tape exhibits a similar property named tape saturation, which is the point where the tape refuses to magnetize deeper when the recorded signal is increased in amplitude. These three examples are just a few of the many options that an analogue electronics designer can use to create a harmonic distortion device. Main characteristic of saturation distortion is that both the positive peak and the negative peak are gradually compressed to a certain maximum signal level. When both the positive and the negative signal peaks are compressed by equal amounts this type of distortion is named symmetrical. Symmetrical distortion will generate only the odd harmonics of a single sine wave input signal or of each partial in the sound. When one of the polarities is compressed slightly less than the peak of the other polarity the distortion is asymmetric, which will result in the generation of extra even harmonics in addition to the odd harmonics. The compressive effect is an important property that can be put to good musical use. Note that this compression effect is instantly and is different to how a studio compressor works; studio compressors use the envelope of an audio signal to slowly control the compression rate, while odd harmonic distortion uses the audio signal itself for immediate compression.

Vacuum tubes have a slightly more complex nonlinear behaviour, as the transfer curve of a tube is slightly asymmetric. This means that positive peaks are compressed differently than negative peaks. This will create both odd and even harmonics, though the odd harmonics will in general have a stronger presence. Designing a tube amplifier is an art by itself as the amplification curve of a tube is bent with a complex curve. A HiFi amplifier designer will try to find a part of the curve that is virtually linear. In contrast, the designer of a guitar amplifier will in general have the tube work in a range in the curve that is highly nonlinear and probably drive the tube into saturation as well, which accounts for the typical character of a distorted guitar sound when a tube-based guitar amplifier is used. Different types and brands of tubes can have different amplification curves, meaning that the type of tube used can make quite a difference to the sound. Often a tube is set to a range where peaks of one polarity are heavily compressed, while the peaks of the other polarity are strongly expanded. The expanded peak will quickly 'explode' to a very high voltage and create lots of very high harmonics, an effect that is sometimes named 'tube screaming'.

Emulation of analog circuitry

The best way to recreate analogue types of distortion by digital means is to use a technology named ACE (Analogue Circuitry Emulation). ACE is similar to physical modelling of acoustic instruments, but instead of modelling the physical aspects of an instrument the physical aspects of a certain analogue component or an analogue circuit is modelled by an algorithm in a piece of computer code. Keep in mind that the basic instructions in a computer chip do not have the quirky properties of analogue components and these properties must always be recreated by writing the proper computer code. ACE is all about how to write such code. It is also possible to patch ACE models on an analog modular synthesizer, in which case the modular synthesizer is used in a similar way as one would use an analogue computer of the late fifties and early sixties of the twentieth century. Mixer modules in combination with signal inverters do the additions and subtractions, while ringmodulator modules and VCA modules are used for multiplications. Fixed voltage modules will provide the necessary parameters.

ACE concentrates on two important aspects of an analogue component or a circuit, 1) the transfer curve and 2) the effect on the frequency spectrum. A discrete analogue component like the germanium diode has a transfer curve that is fixed for the whole audio range. But a more complex analogue distortion circuit can have different transfer curves for different ranges in the audio spectrum. Meaning that to emulate such an analogue circuit a whole lot of transfer curves could be needed. In general this is not much of a problem, as it is often the same curve that simply tends to become more linear in the higher frequency ranges. This has as a result that the higher pitched partials in a sound produce less distortion as lower pitched partials. When only a moderate amount of distortion is used this tends to give the sound a bit more body in the mid range of the spectrum without making it brighter, as most newly generated partials will be in the low and mid ranges of the spectrum. This tends to increase the presence of a sound, which is generally perceived as pleasant. Especially on chords or loops it is often important that a harmonic distortion circuit does not produce a lot of extra energy in the highest parts of the spectrum, as this will lead to problems in a mix with vocals and acoustic instruments and/or destroy the sense of spaciousness in the overall sound. Rule of thumb is that the perceived increase in sonic energy in the very high (> 4kHz) should be considerably less as the sonic energy increase in the mid-high ranges around 2.5 kHz.

Note that digital sound generation and processing algorithms that do not take these ACE principles into account in general sound thin, flat and overly bright compared to pure analogue musical equipment. Even if a piece of analogue equipment is trimmed to have as little THD distortion as possible, it still tends to have a fuller sound as digital equipment. But when e.g. the effect of a tube screamer is required the transfer curve of the distorter might become more and more nonlinear when the pitch goes up, until a certain point in the audio range where a lowpass function kicks in to block the generation of very high partials. This will account for a slightly resonant sonic character of the distortion. E.g. the transition point might be around 2kHz, below this frequency distortion increases for higher pitched partials but above this frequency both distortion and amplification decrease very fast.

Transfer curves

Transfer curves can be modelled by two methods, the first is to use a lookup table that simply describes the nonlinear transfer curve, second is to use a formula that approximates as closely as possible a suitable nonlinear transfer curve. The advantage of using a lookup table is that an accurate measurement of an existing component can be taken to fill the lookup table. Disadvantage is that huge tables must be used, e.g. for a 24-bit signal resolution 3MB of memory is needed to store the table. Another disadvantage is that the table is static and that when different curves for different frequency ranges are needed a whole lot of memory is needed to store the tables, plus a method to interpolate in between tables. In contrast, formulas do not need memory to store tables and have the advantage that formula parameters can be manipulated in real time and be made controllable by varying control signals like modulation oscillators or the actual amplitude envelope of the input signal. Except for some vacuum tubes the transfer curves are often simple polynomial equations with only few and straightforward parameters. Still, using tables or using formulas are both valid within the principles of ACE.

The use of formulas opens up additional territory, as basically any nonlinear function can be used to produce harmonic distortion. So, next to formulas that approximate transfer curves of existing components and circuits, different nonlinear functions can be used which emulate 'fantasy components' that do not exist as such in the real world. Here is of course lots of room for experiments and chances for happy accidents.

The important thing to always keep in mind when creating harmonic distortion of some type is that distortion always works on existing audio material as input. This audio material will have a specific sonic character and the only valid assessment on a certain distortion effect is how it works out on the sonic character of the original audio material. Distortion will add some of its own character and this should blend well with the original character of the input material. If it doesn't blend well, the distortion should be tweaked until it does blend well, or perhaps using the chosen type of distortion wasn't such a good idea after all. In general, distortion will almost always be acceptable on a single pitched sound or a single percussive hit, be a little more difficult to apply on chords or percussive loops, and be very difficult to apply on a whole mix, especially when vocals and acoustic instruments are included in the mix. As a rule of thumb distortion is generally applied per instrument and sometimes separate on each voice in a delicate polyphonic instrument sound. On a monophonic 'fantasy' synthesizer sound distortion can in general be applied in generous amounts without doing much harm. But applying distortion during the mastering process of a recording is in general considered not done, although this might depend on the musical genre. It is also common to use a crossover filter to split the audio spectrum into two or more bands and apply different amounts of harmonic distortion to only the lowest and/or the middle bands, but rarely on the highest band.

A VCA-based harmonic distortion element

The element that is to be described here can emulate both germanium diodes and tape saturation. The idea is to create a gain cell that, when no input is applied, is at exactly unity gain. Then, when the amplitude of the waveform at the input increases, the gain cell will reduce amplification with an approximately logarithmic curve. An important property will be that amplification will never exceed unity gain, which will make it an ideal element to be used in a feedback loop of a tape echo emulation, an overdrive-type distortion, etc., as being below unity gain prevents overload or unwanted oscillations through the feedback path.

In its simplest form the distortion curve is symmetric, but it can easily be adapted to produce a variable amount of even harmonics as well. At the core is a VCA or multiplier that receives a fixed control signal that will cause the VCA to amplify at exactly unity gain. This control signal is named the bias signal. The trick is to extract a modulation signal from the input signal that will modulate the bias signal in a way that the VCA amplification curve will become logarithmic. To accomplish this the modulation signal will have to go from zero to negative when the input amplitude increases towards either a positive or a negative peak. This negative 'bias modulation signal' is simply added to the bias signal, so that when the input signal increases the final control signal for the VCA will drop and decrease the VCA amplification. The most obvious analogue way to derive the bias modulation signal is to use a full wave rectifier circuit and negate its output so it has a negative polarity. A less obvious but superior way is to generate the quadrate of the VCA input signal by feeding it into both inputs of a four-quadrant multiplier module or both inputs of a ringmodulator module, and then negate the output. The quadrate of a bipolar signal will always have a positive value and so will act as a full wave rectifier as well. The reason why this is a superior method when creating harmonic distortion is because the quadrant of a sine wave will also be a sine wave, but with twice the frequency, so only the second harmonic of the input sine wave will be generated. A diode-based full wave rectifier circuit, or an 'absolute value' computer code instruction, will also produce a signal twice the frequency, but already with a lot of harmonics added. These extra harmonics will somewhat limit the possibility of having a controlled gradual build up of harmonics, especially the even harmonics. In contrast, the multiplier/ringmodulator will offer ways to gradually build up a harmonic series from each sine wave partial in the input signal. Note that the partials produced from the partials in the input signal in the multiplier are only the second harmonics of the input partials, and with a suitable technique these new harmonics can be used later to create the higher harmonics in an easy to control way. By using the quadrate to modulate the VCA bias signal it is possible to e.g. gradually build up only an odd harmonics series for each of the partials in the input signal. Or add a gradual build up of an even harmonics series. It will also be possible to exactly calculate the level of all the produced harmonic signals, as when this circuit is expressed as a mathematical formula it closely resembles Chebyshev polynomial formulas. But instead of going deep into the mathematics a hands-on approach will be used that is easy to patch or program and can be tweaked by ear for the final sonic result. Only a few guidelines will be given, but make note that these are quite important to get a stable nonlinear gain cell. From here on it will be assumed that a multiplier or ringmodulator is used for the full wave rectification.

Using a multiplier as a rectifier in the gain cell will produce only little extra sonic energy in the higher parts of the audio spectrum, most sonic energy of the harmonic distortion will be in the middle and lower parts of the audio spectrum. Sonically, this means that harmonic distortion will tend to increase the presence of a sound in the midrange without making it specifically brighter or fuzzy. In contrast, most waveshaping techniques, like clipping etc., do produce a lot of sonic energy in the high part of the audio range and add only little, or even reduce, sonic energy in the low and mid parts of the audio range.

The rectified signal will itself increase when the input signal amplitude increases and when the circuit receives a very strong input signal this bias modulation signal might become so high in amplitude itself that it will cause the final bias signal on the control input of the VCA to become negative. This situation should be avoided, so the rectified and negated input signal should be attenuated in a way that when a signal at system headroom level is fed into the circuit the final VCA bias signal should still be positive. When the input of the full-wave rectifier is taken from the output of the VCA, instead of the VCA input, the chances that the modulated VCA control signal becomes negative is greatly reduced. The reason is that the rectifier will use the already slightly compressed VCA output signal instead of the full level input signal. However, this also creates a feedback situation, the feedback signal flowing from the modulated VCA output to the VCA control signal. This means that although chances of a negative bias signal are greatly reduced, the feedback path will increase the chance that an internal oscillation could occur. The oscillation would prefer half the sample rate as its resonant frequency, which is probably an inaudible frequency but it will make the gain cell highly unstable and unpredictable. This simply means that a balanced choice between two evils has to be made in a way that the final circuit is stable under even extreme working conditions (e.g. a square wave signal that alternates between positive and negative system clipping levels). Analogue feedback circuits suffer from the same tendencies to oscillate, although these circuits prefer radio frequencies. To prevent radio oscillations in analogue circuitry band limiting is used in the feedback path of e.g. operational amplifier circuits. In digital circuitry a similar solution can be used, e.g. by inserting a 6 dB lowpass filter with a cutoff frequency set to about 5% of the sample rate. On a 96kHz system this would be about 5kHz. Inserting a lowpass filter at 5kHz would also suppress the generation of harmonics above 5kHz, which is sonically not a bad thing at all.

Increasing distortion depth

The harmonic distortion produced by the gain cell is only moderate in depth. Still, the sonic effect will be that the presence of the mid range of the audio spectrum seems to be somewhat increased, instead of giving a clear sense of a distorted sound. But on a chord the mentioned grungy low bottom will be clearly present. Distortion depth can be greatly increased by placing the gain cell in the feedback loop of a simple mixer module. One mixer input will receive the audio input signal while the other input receives the output of the VCA. Audio output is still taken from the output of the VCA. In essence this means that the distortion cell is placed in the feedback loop of a mixer's output back to one of its inputs. The compressive action of the distortion cell will keep signal levels in this 'outer loop' in check, while the build up of harmonic partials is intensified by this outer feedback loop. There is a lot of room for experimentation here, e.g. placing a carefully tuned allpass filter in this outer feedback loop it is possible to create the sonic effects of e.g. a tube screamer. On the waveform level the slight phase delay caused by the allpass will create an effect that is similar to the slightly delayed effect of a compressor on a percussive hit, which will emphasise the hit of the percussive sound. When experimenting with this kind of technique it is important to judge the sonic effects by ear; when it sounds good, and there seem to be no internal oscillations caused by exaggerated feedback levels, all is fine.