/*
The pan position influences the highpass filter frequency
for the side signal.

So the more you pan, the more gets the side signal cut off.

100 % pan = max highpass frequency
0 % pan = no highpass
*/

desc: Read info...

slider1:0<-60,24,0.1>Mid (dB)
slider2:0<-60,24,0.1>Side (dB)
slider3:0<-100,100,1>Pan (%)
slider4:1200<20,1200,1>Max HP (Hz)
slider5:0<-24,24,0.1>Output (dB)

import zdf_filter.jsfx-inc

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

@slider
widthmid = slider1 <= -60.0 ? 0.0 : 10^(slider1/20);
widthside = slider2 <= -60.0 ? 0.0 : 10^(slider2/20);

pan = slider3*0.01;
left = pan > 0 ? 1-pan:1;
right = pan < 0 ? 1+pan:1;

x = abs(slider3);
y = 100/slider4;
freq = floor(x/y);
q = 10^(-3 / 20);
hpf0.zdf_hp(freq, q);

output = 10^(slider5/20);

@sample
L = spl0;
R = spl1;

M = (L+R)*0.5;
S = (L-R)*0.5;

M *= 2*widthmid;
S *= 2*widthside;

Shp = hpf0.zdf_svf_hp(S);

outL = ((M+Shp)*0.5)*left;
outR = ((M-Shp)*0.5)*right;

spl0 = outL*output;
spl1 = outR*output;
