slider1:25<20,250,5>Size (ms)
slider2:0<-24,24,1>Zoom gain (dB)

options:no_meter

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

@init

histbuf=1000000;
histpos=0;

@slider

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

zoom_gain=10^(slider2/20);

@sample

histbuf[histpos]=spl0 * -zoom_gain;
histbuf[histpos+histsize]=spl1 * -zoom_gain;

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

spl0=spl0;
spl1=spl1;

@gfx 0 101

offs=histpos;
gscale=gfx_w/histsize;
gbuf=histbuf;
gscale2=gfx_h*0.5;

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=gfx_h*0.5 - gv*gscale2;
ga ? gfx_lineto(gx,gy,0) : ( gfx_x=gx; gfx_y=gy; );
ga+=1;
);

gbuf+=histsize;
