slider1:0<0,48,0.1>Input (dB)
slider2:0<-48,0,0.1>Output (dB)
slider3:25<20,250,5>Size (ms)

in_pin:L in
in_pin:R in
out_pin:L out
out_pin:R out

@init
function shape(z,input) (
kilopascal = 0.686306;
x0 = z * kilopascal * input;
a0 = 1 + exp(sqrt(abs(x0))*-0.75);
((exp(x0) - exp(-x0 * a0)) / (exp(x0) + exp(-x0 * a0)));
);

function shape2(x,input) (
kilopascal2 = 0.686306;
x1 = x * kilopascal2 * input;
a1 = 1 + exp(sqrt(abs(x1))*-0.75);
((exp(x1) - exp(-x1 * a1)) / (exp(x1) + exp(-x1 * a1)));
);

histbuf=1000000;
histpos=0;

@slider
input=10^(slider1/20);
output=10^(slider2/20);

size=slider3;
histsize=size/1000*srate|0;

@sample
spl0 = shape(spl0,input);
spl1 = shape(spl1,input);

spl0 *= output;
spl1 *= output;

histbuf[histpos]=spl0;
histbuf[histpos+histsize]=spl1;

histpos+=1;
histpos >= histsize ? histpos=0;

@gfx 0 101
gfxSize=min(gfx_w,gfx_h);

gfx_r=gfx_g=gfx_b=0; gfx_a=1;
gfx_x=gfx_y=0;
gfx_rectto(gfx_w,gfx_h);

gfx_r=gfx_g=gfx_b=0.8; gfx_a=1;
gfx_x=gfxSize/2;
gfx_y=0;
gfx_lineto(gfxSize/2,gfxSize,0);
gfx_x=0;
gfx_y=gfxSize/2;
gfx_lineto(gfxSize,gfxSize/2,0);

gfx_r=0.5; gfx_g=1; gfx_b=0; gfx_a=1;
gfx_x=0;
gfx_y=gfxSize;
x = -1;
while(
y = -shape2(x,input);
gfx_lineto(x*gfxSize/2+gfxSize/2,y*gfxSize/2+gfxSize/2,1);
(x+=0.001) <= 1;
);
gfx_lineto(gfxSize-1,0,1);

offs=histpos;
gscale=gfxSize/histsize;
gbuf=histbuf;
gscale2=gfxSize/2;

gfx_r=0; gfx_g=1; gfx_b=1; gfx_a=0.5;

ga=0;
loop(histsize,
gv=gbuf[offs];
offs+=1;
offs>=histsize?offs=0;
gx=ga*gscale;
gy=gfxSize/2 - gv*gscale2;
ga ? gfx_lineto(gx,gy,0) : ( gfx_x=gx; gfx_y=gy; );
ga+=1;
);

gbuf+=histsize;
