Hello,
I've started to work on a series of little JS plugins that are intended to work together.
They will be Mono (as in "not Stereo") and Mono (as in "not polyphonic", sorry IXix).
The idea is to combine them in series or parallel using the routing facilities of Reaper.
Here is the first one, it is an Anti Aliased Tube Saturation.
I've started to work on a series of little JS plugins that are intended to work together.
They will be Mono (as in "not Stereo") and Mono (as in "not polyphonic", sorry IXix).
The idea is to combine them in series or parallel using the routing facilities of Reaper.
Here is the first one, it is an Anti Aliased Tube Saturation.
Code:
desc:TiaR M Tubey Sat
// Author: T.Rochebois 09/2016
slider1:sl_drive=0.1<0,1>Drive
in_pin:Sat Input
out_pin:Sat Output
// _____________________________________________________________________
@init
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// interpolator
function int2_3(x) instance(x0 x1 x2 x3 x4 x5 y0 y1)(
x0 = x1; x1 = x2; x2 = x3; x3 = x4; x4 = x5; x5 = x;
y0 = x2;
y1 = (x5 + x0) * 0.025665914601895386
+ (x4 + x1) * -0.04277652433649233
+ (x3 + x2) * 0.517110609734597;
);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
// decimator
// -96dB 17.5kHz at 44.1kHz ov2 -> srate
// 16 x 30 +
function dec2_96_59(x0 x1)
instance(R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15
R16 R17 R18 R19 R20 R21 R22 R23 R24 R25 R26 R27 R28 R29 R30)
local(h1x0 h3x0 h5x0 h7x0 h9x0 h11x0 h13x0 h15x0
h17x0 h19x0 h21x0 h23x0 h25x0 h27x0 h29x0) (
h1x0 = x0*0.3167967114236291; h3x0 = x0*-0.10164126581474016;
h5x0 = x0*0.056472878314649574; h7x0 = x0*-0.03590356425550024;
h9x0 = x0*0.023854182328325296; h11x0 = x0*-0.015966909428751137;
h13x0 = x0*0.010553528578562761; h15x0 = x0*-0.006794829937625732;
h17x0 = x0*0.004212042043030732; h19x0 = x0*-0.002484841082005066;
h21x0 = x0*0.0013753503068182293; h23x0 = x0*-0.0007008749315804081;
h25x0 = x0*0.00031898286827647583; h27x0 = x0*-0.00012279053509672562;
h29x0 = x0*0.000035881628440564505;
R30 = R29 + h29x0; R29 = R28 + h27x0;
R28 = R27 + h25x0; R27 = R26 + h23x0; R26 = R25 + h21x0;
R25 = R24 + h19x0; R24 = R23 + h17x0; R23 = R22 + h15x0;
R22 = R21 + h13x0; R21 = R20 + h11x0; R20 = R19 + h9x0;
R19 = R18 + h7x0; R18 = R17 + h5x0; R17 = R16 + h3x0;
R16 = R15 + h1x0;
R15 = R14 + h1x0 + 0.50000063464071 * x1;
R14 = R13 + h3x0; R13 = R12 + h5x0; R12 = R11 + h7x0;
R11 = R10 + h9x0; R10 = R9 + h11x0; R9 = R8 + h13x0;
R8 = R7 + h15x0; R7 = R6 + h17x0; R6 = R5 + h19x0;
R5 = R4 + h21x0; R4 = R3 + h23x0; R3 = R2 + h25x0;
R2 = R1 + h27x0; R1 = h29x0;
R30;
);
// _____________________________________________________________________
// Table "allocation"
function PIT_init(n)(
this.n = n; this.n16 = n * 16;
this.dv = ad; ad += n; this.v = ad; ad += n;
this.Iv = ad; ad += n; this.IIv = ad; ad += n;
);
// _____________________________________________________________________
function PIT_update()
instance(n dv v Iv IIv) local(p dcOffset)(
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dcOffset = v[0]; p = 1; loop(n - 1, dcOffset += v[p]; p += 1; );
dcOffset /= n; p = 0; loop(n, v[p] -= dcOffset; p += 1; );
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
p = 0; loop(n, dv[p] = v[(p+1) % n] - v[p]; p += 1; );
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dcOffset = Iv[0] = 0; 0; p = 0;
loop(n - 1,
Iv[p+1] = Iv[p] + v[p] + 0.5 * dv[p];
dcOffset += Iv[p+1]; p+=1; );
dcOffset /= n; p = 0; loop(n, Iv[p] -= dcOffset; p += 1;);
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dcOffset = IIv[0] = 0;
p = 0; loop(n - 1,
IIv[p+1] = IIv[p] + Iv[p] + 0.5 * v[p]+(1/6)*dv[p];
dcOffset += IIv[p+1]; p+=1; );
dcOffset /= n;p = 0;loop(n, IIv[p] -= dcOffset;p+=1;);
);
// _____________________________________________________________________
function PIT_I0(p)
instance(n n16 dv v) local(p0 a)(
a = p - (p0 = p|0); // "a" is the float part, "p0" is the integer part
p0 %= n; // be modulo
dv[p0] * a + v[p0];
);
// _____________________________________________________________________
function PIT_I1(p)
instance(n n16 dv v Iv) local(p0 a)(
a = p - (p0 = p|0);
p0 %= n;
( dv[p0] * 0.5*a + v[p0]) * a + Iv[p0];
);
// _____________________________________________________________________
function PIT_I2(p)
instance(n n16 dv v Iv IIv) local(p0 a)(
a = p - (p0 = p|0);
p0 %= n;
(( dv[p0] * (1/3)*a + v[p0]) * 0.5*a + Iv[p0]) * a + IIv[p0];
);
// _____________________________________________________________________
function PIO_link(pit*)(
this.dv = pit.dv; this.v = pit.v;
this.Iv = pit.Iv; this.IIv = pit.IIv;
this.n = pit.n; this.n16 = pit.n16;
);
// _____________________________________________________________________
// Processing function
function PIO_aProc2(m)
instance(p n x1 x2 I2_1 I2_2 y0 y1 I1_0 I1_1 out)(
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x1 = x2; I2_1 = I2_2; x2 = m; I2_2 = this.PIT_I2(x2);
y0 = y1; I1_0 = I1_1; y1 = 0.5 * (x2 + x1);
I1_1 = abs(x2 - x1)<0.0001 ? this.PIT_I1(y1) : (I2_2 - I2_1) / (x2 - x1);
out = abs(y1 - y0)<0.01 ? this.PIT_I0(0.5*(y0+y1)) : (I1_1 - I1_0) / (y1 - y0);
);
// _____________________________________________________________________
function PIO_update2()
instance(p x1 x2 I2_1 I2_2 y0 y1 I1_0 I1_1 out)(
I2_2 = this.PIT_I2(x2);
I1_1 = x1 == x2 ? this.PIT_I1(y1) : (I2_2 - this.PIT_I2(x1)) / (x2 - x1);
);
// _____________________________________________________________________
pit.PIT_init(256);
i=0;loop(pit.n,
x = i < pit.n / 2 ? i : i - pit.n;
x *= 0.2;
x > 0 ? pit.v[i] = x / ((1+abs(x)^2.5)^(1/2.5))
: pit.v[i] = x / ((1+abs(x)^4.0)^(1/4.0));
i+=1;
);
pit.PIT_update();
pio.PIO_link(pit);
pio.PIO_update2();
// _____________________________________________________________________
@slider
gDrive = sl_drive * pit.n*0.5;
// _____________________________________________________________________
@sample
gDriveSmooth += 0.01 * (gDrive - gDriveSmooth);
x = gDriveSmooth * spl0;
x = max(-125, min(125,x));
interp.int2_3(x + pit.n16-0.03717);
spl0 = dec2_96_59(
pio.PIO_aProc2(interp.y0),
pio.PIO_aProc2(interp.y1)
);
// _____________________________________________________________________
@gfx
gfx_g = 0.5;
gfx_line(8, 38, 8+2*pit.n, 38);
gfx_g = 1;
gi = 0; loop(pit.n-1,
gfx_line(8+2*gi, 38-30*pit.v[(gi +pit.n/2)%pit.n],
10+2*gi, 38-30*pit.v[(gi+1+pit.n/2)%pit.n],1);
gi+=1;
);
JSFX: TiaR_M Series
Aucun commentaire:
Enregistrer un commentaire