View Single Post
Old 07-08-2019, 12:48 PM   #15
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 173
Default

Quote:
Originally Posted by sai'ke View Post
What SaulT says is right of course. Discontinuities in waveshapers are typically evil and his way is a good way of ensuring continuity

Though, depending on the purpose of the waveshaper, hitting a wall at 1 might be what's desired.

One thing that can also be done is to make a smooth transition between two shapers using a smooth interpolation function.

Computationally cheap examples are:
Code:
xi = min(abs(x), 1);
x2 = xi*xi;
x3 = x2*xi;
interp = 3*x2-2*x3;
Or smoother yet:

Code:
xi = min(abs(x), 1);
x2 = xi*xi;
x3 = x2*xi;
x4 = x2*x2;
x5 = x3*x2;
interp = 6*x5-15*x4+10*x3;
Code:
clipper = sign(x);
out = b*sin($pi*x)+x;

result = out * (1-interp) + clipper * interp;
You can also shift these things around if you want the interpolation function to start later. They're relatively cheap ways of piecing things together

Edit: One thing to keep in mind with these is that the interpolation weight should be zero for any discontinuous parts of the shapers being interpolated between (which is the case for the sign shaper, since it has its discontinuity at zero).
Hi and thanks This is a bit beyond me. Im gonna need to try and code this slowly.

Best regards /Bo
danerius is offline   Reply With Quote