Page 1 of 1

Soft clipper

PostPosted: Fri Apr 07, 2017 8:31 am
by Logado
i need create soft clipper (distortion)
The curve and harmonics are very similar to free plugin Gclip.
I found a formula that gives the right harmonics
Code: Select all
sample / pow(1 + pow(fabs(sample), alpha), 1.0f / alpha)

where alpha 2.5
but 2 power and 2 divisions per sample :cry: :cry:
Can there is another way to get this curve?
i try in desmos
https://www.desmos.com/calculator/ujkvajglhj
I did not succeed, can anyone have more experience in mathematics?

Re: Soft clipper

PostPosted: Fri Apr 07, 2017 4:54 pm
by TheOm
That's very close to the good old tanh(x). I'm not familiar with that plugin but I assume that's what it's using since that function is very popular.
Now tanh itself is also expensive to compute, but you can get away with very rough polynomial approximations.
You can find some on google.

Re: Soft clipper

PostPosted: Fri Apr 07, 2017 11:47 pm
by martinvicanek
There are fast stream functions over at FS Guru which you could use. Alternatively, try

Code: Select all
y = x/sqrt(1 + x^2)


which is even closer to your formula than tanh(x).

Edit: Sorry if this information was cursory. Here is a schematic with optimised transfer curves.

Re: Soft clipper

PostPosted: Mon Apr 10, 2017 12:09 pm
by Logado
thanks for tips, distortion is an interesting area, so much magic happens here :)

Re: Soft clipper

PostPosted: Mon Apr 10, 2017 7:56 pm
by BobF
Hello Logado,

DO some searches on the forum, but just not for distortion, but clipper, wave shapers, fuzz, square wave (etc), rectifiers, and so on. You will find many examples of magic. Feed them with a sine wave and then out to a windowed FFT display and you can view the harmonics.

Have fun.
Cheers, BobF.....

Re: Soft clipper

PostPosted: Tue Apr 11, 2017 12:31 am
by Logado
BobF wrote:Hello Logado,

DO some searches on the forum, but just not for distortion, but clipper, wave shapers, fuzz, square wave (etc), rectifiers, and so on. You will find many examples of magic. Feed them with a sine wave and then out to a windowed FFT display and you can view the harmonics.

Have fun.
Cheers, BobF.....

I think I've seen ~90% of osm files from the forum :) I learned dsp with the help of this forum (thank you). Now I'm using the juce. I want to learn how to emulate different devices. But the smallest difference in the curve no longer gives the harmonics that need. I'm thinking of experimenting with a wave shaper with a table without formulas. I wonder what will come out