// Useful for putting it in front of an amp sim,
// as it straightens the input signal somehow with extreme 'gain' settings...

slider1:0.5<0,1,0.01>gain
slider2:1<0,2,0.01>output
slider3:0<0,1,1{mono,stereo}>mode

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

@init
src_gain=tgt_gain=2+(slider1-1);
src_output=tgt_output=slider2;

@slider
tgt_gain=2+(slider1-1);
tgt_output=slider2;
mode=slider3;

@block
d_gain=(tgt_gain-src_gain)/samplesblock;
tgain=src_gain;
src_gain=tgt_gain;

d_output=(tgt_output-src_output)/samplesblock;
toutput=src_output;
src_output=tgt_output;

@sample
tgain+=d_gain;
gain=tgain;

toutput+=d_output;
output=toutput;

mode ? (

x0=spl0*gain;
x1=spl1*gain;

x0>=1? y0=0.5;
(x0<1||x0>0)? y0=(-0.5*x0^2)+x0;
x0<=-1? y0=-0.5;
(x0<0||x0<-1)? y0=(0.5*x0^2)+x0;

x1>=1? y1=0.5;
(x1<1||x1>0)? y1=(-0.5*x1^2)+x1;
x1<=-1? y1=-0.5;
(x1<0||x1<-1)? y1=(0.5*x1^2)+x1;

gain<1 ? gain=1/gain;

spl0=y0*gain*output;
spl1=y1*gain*output;

):(

x=(spl0+spl1)*0.5*gain;

x>=1? y=0.5;
(x<1||x>0)? y=(-0.5*x^2)+x;
x<=-1? y=-0.5;
(x<0||x<-1)? y=(0.5*x^2)+x;

gain<1 ? gain=1/gain;

spl0=y*gain*output;
spl1=y*gain*output;

);
