How the frick does good distortion actually work and/or how do I analyze it?

DSP, Plug-in and Host development discussion.
MusterMyMan
KVRer
16 posts since 29 May, 2019

Post Fri Jan 17, 2020 3:54 am

I've always thought that distortion algorithms were just a constant, instant mapping from input to output. So to analyze different distortion plugins I own, I've run them through a clean, aliased sawtooth wave at a very low frequency to get a rough picture of what the distortion looks like. The issue is that even using the same saw wave at different frequencies gives different results and in one case, even the same saw wave at the same frequency but reversed (i.e. rising instead of falling) does not result in a mirrored shape but one with inversed polarity instead, weirdly enough.
I know that the plugins I've tested do filter the signal, but does that explain all the other behavior?
I feel like I'm missing something critical here. Can someone help me out?

User avatar
EvilDragon
KVRAF
19318 posts since 7 Jan, 2009 from Croatia

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Fri Jan 17, 2020 4:08 am

If there's any sort of pre/post filtering in the distortion plugin that you can't bypass, it's likely that phase of the input signal is going to be affected.

MusterMyMan
KVRer
16 posts since 29 May, 2019

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Fri Jan 17, 2020 5:01 am

It is definitely being affected, the filtering done pre-distortion is certainly not linear phase.

mystran
KVRAF
5570 posts since 12 Feb, 2006 from Helsinki, Finland

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Fri Jan 17, 2020 7:55 am

EvilDragon wrote:
Fri Jan 17, 2020 4:08 am
If there's any sort of pre/post filtering in the distortion plugin that you can't bypass, it's likely that phase of the input signal is going to be affected.
Not necessarily just pre/post filtering, since there might also be feedback, which essentially turns the distortion itself into a filter of sorts, which means it might even produce different results for different cycles of a static waveform. Most commonly this involves some variation of using feedback to keep the non-linearity from running into constant saturation, for example by dynamically adjusting bias to counter the DC offsets in the output, but really the possibilities are kinda endless.

That said, the very first thing you usually want to do to improve the sound of a static waveshaper is to put some EQ in front to cut the low-frequencies. If you don't want to lose them, then just boost them back up afterwards. This way you actually get more interesting distortion action in the higher frequencies (as the lowest frequencies aren't so dominant), rather than just turning everything into a square-wave at the fundamental frequency.
Please just let me die.

Z1202
KVRian
1122 posts since 12 Apr, 2002

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Fri Jan 17, 2020 1:48 pm

mystran wrote:
Fri Jan 17, 2020 7:55 am
Most commonly this involves some variation of using feedback to keep the non-linearity from running into constant saturation, for example by dynamically adjusting bias to counter the DC offsets in the output
Or to artificially create DC offset in the input to avoid turning everything into a square-wave at the fundamental frequency :D

Z1202
KVRian
1122 posts since 12 Apr, 2002

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Fri Jan 17, 2020 1:57 pm

mystran wrote:
Fri Jan 17, 2020 7:55 am
which essentially turns the distortion itself into a filter of sorts
To put what mystran said in a short and catchy form, I would say that generally DSP-wise a distortion is rather a highly nonlinear filter than a mere waveshaper.

User avatar
EvilDragon
KVRAF
19318 posts since 7 Jan, 2009 from Croatia

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Fri Jan 17, 2020 2:24 pm

That's interesting. I've never thought about distortion that way!

MusterMyMan
KVRer
16 posts since 29 May, 2019

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Fri Jan 17, 2020 6:09 pm

Z1202 wrote:
Fri Jan 17, 2020 1:57 pm
To put what mystran said in a short and catchy form, I would say that generally DSP-wise a distortion is rather a highly nonlinear filter than a mere waveshaper.
Hm. I think this is the crux of the matter. Do you have any recommended resources (books or websites) that explain non-linear filters or distortion algorithms that go beyond wave shaping?

DaveClark
KVRist
184 posts since 8 May, 2007

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Sat Jan 18, 2020 9:24 am

Others may have better suggestions, but Figure 8.1 in the following book gives a somewhat familiar-looking example to give you one approach. It's a recursive filter but has nonlinear elements:

V. John Mathews and Giovanni L. Sicuranza. Polynomial Signal Processing. John Wiley and Sons, Inc., 2000, page 306.

Although I've played around with such filters, I prefer filter, asymmetric wave-shaper, filter, asymmetric wave-shaper, filter, asymmetric wave-shaper, ... i.e. multiple stages of wave-shapers with filters before and after. As long as the filters are carefully designed, the wave-shaper can be rather crude, in my experience.

Regards,
Dave Clark

MusterMyMan
KVRer
16 posts since 29 May, 2019

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Sun Jan 19, 2020 6:13 pm

Nice, thanks, Dave!

Z1202
KVRian
1122 posts since 12 Apr, 2002

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Mon Jan 20, 2020 6:03 am

I'm not really into distortions, but from my very limited experience and knowledge, distortions usually make quite heavy use of the "nonidealities" of electronic components. In comparison, with typical analog VCFs there is usually a small number of nonidealities which is essential for the sound (e.g. in a Moog VCF the most essential nonideality is probably just the tanh saturation arising from a differential transistor pair). The problem is aggravated by the fact that some (or even many) of these nonidealities are not intended, but simply "happen" by nature of electronic components. I'm not sure how many nonidealities are essential in a typical distortion, still I've yet to see a qualitative analysis of any distortion box other than a simple diode clipper which lists the equations of even a simplified model, something even comparable to the mentioned model of the Moog VCF.

KBonzo
KVRer
13 posts since 21 Feb, 2019

Re: How the frick does good distortion actually work and/or how do I analyze it?

Post Sat Feb 22, 2020 10:52 am

Z1202 wrote:
Mon Jan 20, 2020 6:03 am
I'm not really into distortions, but from my very limited experience and knowledge, distortions usually make quite heavy use of the "nonidealities" of electronic components. In comparison, with typical analog VCFs there is usually a small number of nonidealities which is essential for the sound (e.g. in a Moog VCF the most essential nonideality is probably just the tanh saturation arising from a differential transistor pair). The problem is aggravated by the fact that some (or even many) of these nonidealities are not intended, but simply "happen" by nature of electronic components. I'm not sure how many nonidealities are essential in a typical distortion, still I've yet to see a qualitative analysis of any distortion box other than a simple diode clipper which lists the equations of even a simplified model, something even comparable to the mentioned model of the Moog VCF.
The nonideality in something like a Moog VCF is distortion. It's just a matter of degree. A transistor is a nonlinear device. It will therefore distort unless you take measures to linearise the circuit such as using negative feedback. A diode is also nonlinear. The assumption in this thread is that distortion is a desirable property of analogue circuits that we need to emulate. The analogue circuit has set the standard for good distortion. I'm a guitar player with an analogue background so I love analogue distortion but I think the situation will change in the future because DSP is not limited by the transfer function of a diode or transistor.

Return to “DSP and Plug-in Development”