View Single Post
 06-21-2015, 10:28 AM #3 Tale Human being with feelings     Join Date: Jul 2008 Location: The Netherlands Posts: 3,085 Yep, the cubic version is faster, especially when you stack multiple stages: Code: ```desc:Another loser/Saturation rewrite, thanks to SaulT! slider1:0<0,1,0.01>Saturation slider2:1<1,10,1>Stages slider3:1<0,1,1{Sine,Cubic}>Function // Sine: f(x) = sin(x * a * 0.5 * pi)/sin(a * 0.5 * pi) // Cubic: f(x) = ((x*a)-((x*a)^3)/3)/(a-(a^3)/3) @init scale = 1.1 / 3; @slider a = max(0, min(1, slider1)); a > 0 ? ( n = max(1, floor(slider2 + 0.5)); f = slider3 < 0.5; gain = 1 - (1 - 1/n) * a; div = 1/(f ? sin(a *= 0.5*\$pi) : a - a*a*a * scale); ); @sample a > 0 ? ( x0 = max(-1, min(1, spl0)); x1 = max(-1, min(1, spl1)); f ? loop(n, x0 = sin(x0 * a) * div; x1 = sin(x1 * a) * div; ) : loop(n, x0 *= a; x0 = (x0 - x0*x0*x0 * scale) * div; x1 *= a; x1 = (x1 - x1*x1*x1 * scale) * div; ); spl0 = x0 * gain; spl1 = x1 * gain; );``` Note that I have slightly scaled the cubic version, so it better matches the output level of the sine version. __________________ Martinic Kee Bass - Scanner Vibrato - Elka Panther - Lem Echo Music - Tale's JSFX Pack