soft clipping

This commit is contained in:
Alex Janka 2022-07-24 15:00:36 +10:00
parent 437f3ed2be
commit 6a09623022

View file

@ -3,7 +3,7 @@ import("aanl.lib");
import("maths.lib"); import("maths.lib");
import("basics.lib"); import("basics.lib");
process = driver : wrapper : aa.hardclip2 : trimmer; process = driver : wrapper : softclip : aa.hardclip2 : trimmer;
driver(x) = x * drive * squeeze; driver(x) = x * drive * squeeze;
trimmer(x) = x * (1 / squeeze); trimmer(x) = x * (1 / squeeze);
@ -18,3 +18,13 @@ slider_raw = nentry("clipping", 0, 0, 1, 0.01);
slider = (.85*slider_raw)+0.15; slider = (.85*slider_raw)+0.15;
fadeamt = min(20*slider_raw, 1); fadeamt = min(20*slider_raw, 1);
clipamt = max(ma.EPSILON, (slider^2)*20); clipamt = max(ma.EPSILON, (slider^2)*20);
softclip = softclipamt, _ : softclip_maths ;
softclip_maths( a1, x ) = min( a0 , atan((a0 - a1)/a2 ) * a2 + a1 ) * a3
with{
a0 = abs(x);
a2 = (1-a1) * 2/ma.PI ;
a3 = ma.signum(x) ;
};
softclipamt = db2linear(nentry("softclip", 0, 0, 1, 0.01) * -3) : si.smoo;