SynthMaker

How to deliberately create THD

Archive · 2012 19 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

rocko ·

Dear all,

I'm interested in deliberately creating controlled THD.

That is to take any signal and produce higher harmonics out of it, odd or even harmonics.

I'm interestead in this for "saturation modelling" and such.

Any efficient way besides finding the frequency and creating higher harmonics synthetically?

Thanks, Rocko

Dell ·

THD is based on a signal that is overdriven. The stock plug-in labelled "Overdrive" will give you an idea what an audio signal will sound like using various settings of the control knob. The Harmonics is based on peaks of the audio signal and varies from song to song.

The peaks are frequency driven and co-respond to the initial frequency note however, at a lower dB level than the initial frequency note being excited.

Bear in mind saturation and THD do not sound the same. THD is more to wards an amplifier being heavily clipped whereas saturation is some means of tape deteriorating.

rocko ·

Thanks, I'll look into this.

treacherousumbrella ·

When the signal is overdriven the addition of harmonics will result. The specific mix of harmonics generated is highly dependant on how the system overdrives. Hard clipping (flatline) distortion is commonly found in digital systems and will produce only odd harmonics. Assymetric distortion produces a mix of odd and even. A good first step would be to pass a sine wave through the system you are attempting to model and analyse both the waveform and frequency response of the result.

rocko ·

Hi,

Let's say I'm trying to model a tube compressor (I'm not, just learning and inquiring, but OK).

First stage - imitating the amplitude curve: I'll measure the dynamic range curve and "imitate it" in digital domain. Now I get a "natural" by-product THD simply due to the fact that I use a non-linear amplitude curve. Right? This is true to any compressor - clean as can be. It's a "mathematical THD" which can not be avoided, right?

second stage - imitating the added THD: Now I'm trying to add the "tube" THD - without reshaping the amplitude curve. How is this done?

Thanks

trogluddite ·

rocko wrote: Bear in mind saturation and THD do not sound the same

Not strictly speaking true. THD is not any particular sound - it is a scientific measure of how much the output sound differs in harmonic content from the input sound. Its main use is to provide a means of describing any unintended consequences of processing a signal, so that you can judge the quality of the engineering - i.e. a pre-amplifier with very low THD gives a more accurate rendering of the signal coming from a mic. THD also tells you nothing about the spectrum of the added (or removed) harmonics that make the output sound different - it is a weighted total of all of the harmonics, when tested with a calibrated test signal. Which is why it is called 'Total Harmonic Distortion'. So the accurate answer to 'how do I create deliberate THD' is to do just about anything to the signal that changes it (except for a pure gain change).

OK, OK, sorry, I am being pedantic and I sound like your boring science teacher at school - not very useful for what you are after - lecture over 😉

Different kinds of distortion will give you different kinds and amounts of added harmonics. The two biggest factors to play with, I would say, are... 1) The 'severity' of distortion - i.e. do you just 'bend' or 'round off' the waveform, or at the other extreme, just hard clip it to make a very 'angular' shape. 2) Symmetry - distorting the positive and negative halves of a wave in different ways or by different amounts will sound very different than if they are both distorted in the same way.

For valve simulation there is also another big factor that often comes into play - compression. When you drive a valve hard, it has a lot more work to do, which leads to some gain reduction that doesn't just change the shape of individual wave cycles - it acts over a slightly longer period of time (but not as usually slow as common compressor settings). So to get a nice valve simulation, you will probably need more than one stage of processing to get the complete sound.

rocko ·

Thanks trog !

Dell ·

Any audio hardware product can/will distort based on the following things.

The Power Supply

The Input Section

The Output Section

Various components in between

All four are stressed under various conditions and will contribute to the sound.

Valves vary considerably on how they will react under the given conditions. This applies to semiconductors as well. From my experience using valves, achieving a sound of audio equipment using valves requires a lot of measuring on all aspects of the component. Valves are very unpredictable and are never 100% accurate.

This is due to the errors valves bring forth in addition to the other components (which cannot be emulated in a plug-in) contributing to the sound.

If you were planning to pursue such a project, it would be best to own some type of valve equipment. There are lots of valve emulations running about that sound more to wards a small transistor radio than valve audio equipment.

Be careful of making your design offering too much characteristics as hardware if you plan to offer it to the public. The majority of users wanting the valve sound do not have any experience using hardware equipment. If the characteristics are too realistic you will find yourself explaining numerous times how to use your design due to the user assuming your design is going to work just as the typical vst plug-in.

rocko ·

Hi,

Thanks for the detailed response.

I'm more into the theoretical sound of how to create THD which is not a side effect of dynamic range compression.

By this I mean, how to create extra harmonics (i.e related to the fundamental of the input) - without directly changing the dynamic range.

What is the mathematical action used to add more harmonies? I mean the 'THD adding' algorithms do not really pin-point the frequency and then create harmonies with oscilators, right?

Thanks, Rocko

treacherousumbrella ·

I'm not sure where you're going with this but have a look at Chebyshev polynomials

trogluddite ·

Dell wrote: If the characteristics are too realistic you will find yourself explaining

He he, too true. The guys that made original valve gear were mostly trying to achieve very low THD - i.e. excellent quality linear reproduction of the sound - they would mostly have considered adding deliberate THD to be poor engineering! Deliberate distortion (e.g. for lead gutar) is a different matter - but a lot of the 'virtual valve'/'virtual transformer'/'virtual tape' plugins out there tend to be completely overcooked. I think a lot of younger musicians and producers would be rather disappointed with well engineered valve hardware - the effect is really very subtle, even when you have well trained ears.

rocko wrote: 'THD adding' algorithms do not really pin-point the frequency and then create harmonies with oscilators, right?

There are maybe a few exceptions, but yes that is pretty much the case - after all, the gear you are trying to emulate did not do it that way either. The additional harmonics would not be totally pure odd or even etc. - just that different circuits will have a characterisitc spectrum that has a bias towards different tone colours. For example, one reason why guitarists tend to prefer valves over transistors is that a good valve circuit tends to be stronger in even harmonics, whereas many transistor circuits create more odd harmonics. Research has shown that most people perceive even harmonics as more musical, and odd harmonics as more 'jarring'.

rocko ·

Hi,

Again this is just a 'theoretical discussion' - I ain;t building emulations I just want to better understand how they work.

So, Trog - your saying that engineering a SM module that adds THD involves a:

1. FFT (or other) frequency finding algorithm 2. Oscilators that are tuned to the found frequency and add harmonics (odd/even)

There must be an easier/simpler/less CPU consuming way to create harmonies (again - indifferent to dynamic range ilinearities).

Rocko

trogluddite ·

rocko wrote: So, Trog - your saying that engineering a SM module that adds THD involves

Sorry, I wasn't too clear - I was agreeing with you that FFT etc. is not the usual way to do it! 🙂

Dell ·

rocko wrote: Hi,

Thanks for the detailed response.

I'm more into the theoretical sound of how to create THD which is not a side effect of dynamic range compression.

By this I mean, how to create extra harmonics (i.e related to the fundamental of the input) - without directly changing the dynamic range.

What is the mathematical action used to add more harmonies? I mean the 'THD adding' algorithms do not really pin-point the frequency and then create harmonies with oscilators, right?

Thanks, Rocko

You cannot make a mathematical equation on THD for there is no standard on THD.

Hopefully what I am about to say is not outside your realm of understanding for certain things cannot be explained no other way.

The graph below illustrates two raw loudspeakers getting pink noise. As you can see, the second and third harmonic distortion differs per graph despite both loudspeakers getting pink noise. The graph stems from both loudspeakers offering the same model number however one is an older version while the other is a newer version.

Trying to make a mathematical equation on THD requires a lot of work and will not guarantee it will reflect every loudspeaker on the market.

Like loudspeakers, valves stem from different manufactures, plants in addition to generations. So how does one create THD using mathematics? You can only choose a device in which you have the proper tools to literally measure (Its rare if you could find VST developer with the proper tools to make such measurements) the device and accept it will only reflect one device out of the thousands of devices manufactured.

Even using convolutions cannot guarantee accurate results for, like a loudspeaker, a valve’s performance vary based in the environment it resides in. The unpredictability of valves is precisely why trying to make a mathematical standard in terms of THD is like trying to catch your shadow.

Dell ·

trogluddite wrote: Dell wrote: If the characteristics are too realistic you will find yourself explaining

He he, too true. The guys that made original valve gear were mostly trying to achieve very low THD - i.e. excellent quality linear reproduction of the sound - they would mostly have considered adding deliberate THD to be poor engineering! Deliberate distortion (e.g. for lead gutar) is a different matter - but a lot of the 'virtual valve'/'virtual transformer'/'virtual tape' plugins out there tend to be completely overcooked. I think a lot of younger musicians and producers would be rather disappointed with well engineered valve hardware - the effect is really very subtle, even when you have well trained ears.

I've must of heard this countless times from users with no experience in valves state the following "I never heard a tube before but, I'm sure this insert the plug-in here sounds like a tube....... 😕 ...... Oh dear 😝

Have you seen this video?

http://www.youtube.com/watch?v=BYTlN6wj ... ature=plcp

The discussion tries the educate the uninformed yet, many lash out because they cannot differentiate mind over matter.

rocko ·

Hi all,

I've started a broad discussion, but now think it has gone to broad, so let me narrow it back by using a specific example.

Let's say I know exactly what series of added harmonics I want. For the example, let me choose at least 6 harmonics, both odd and even and at the ratio of 0.1 from the original tone.

So, if the original tone at input is 100 Hz @ -3 [DbFS] I would like to receive at output 7 tones:

- Original - 200 Hz @ -23 [DbFS] - 300 Hz @ -23 [DbFS] - 400 HZ @ -23 [DbFS] - 500 Hz @ -23 [DbFS] - 600 Hz @ -23 [DbFS] - 700 Hz @ -23 [DbFS]

What is the most effiecient way to create this output?

As mentioned by Trog, I'm sure that there is a more efficient way than just detecting the input (FFT or zero cross count) and then synthesizing the sine waves based on that.

So, that is the core of my question - what mathematical function do the pro VST plug-ins use to "deliberately create THD" for the general case.

Thanks

Andrew J ·

Take a look at Chebyshev Polynomials. However note that you'll find it difficult to implement this with 7 harmonics in SM without getting a fair bit of aliasing. Oversampling filters with only 32 bit coefficients just don't cut the mustard.

Nantonos ·

rocko wrote: That is to take any signal and produce higher harmonics out of it, odd or even harmonics.

I'm interestead in this for "saturation modelling" and such.

Any efficient way besides finding the frequency and creating higher harmonics synthetically?

As it happens, this is what I did for my first, getting my feet wet, synthmaker project. I was trying to model a 1950's valve oscillator (an Advance H1), and the manufacturer specified that the distortion was approximately equal amounts of second harmonic, third harmonic, and mains hum.

You don't need to 'find the frequency', just take it from the midi in component and multiply to generate harmonics.

Crappy osm attached (has no GUI yet). Comments welcome. Please ignore the failed attempt to make drift with a random number generator and detuner.

rocko ·

Hi,

Thanks for the suggested help and answer, however I'm looking into an effect, i.e. the audio is given to me as is, not as MIDI.

But - as mentioned before, the answer is given by Chebyshev polynomials.

Thanks all !

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.