/*
delta_send  ---> FX --->  delta_receive

FX = compressor, gate, limiter or eq (but can be any FX, just experiment !)


The sender should route your signal to an unused channel pair.
The receiver should receive from that channel pair.
So if your track has only two channels, set the track to have 4 channels
and set the sender to output to 3+4 and the receiver to receive from 3+4.


There are five output modes:

1: Dry: The FX is bypassed. You will hear only the original signal.
           Output: channel 1+2.
           Good for A/B comparison (Switch between Wet/Dry !!!).
2: Wet: You will simply hear the FX output signal.
           Output: channel 1+2.
3: Delta: You will only hear the Delta signal.
             Output: channel 1+2.
             Delta = The signal before the FX, subtracted from the signal after the FX.
             This is good for finetuning a compressor or a gate, etc. ...
             as you will hear only the stuff that is actually 'processed' by the FX...
4: Wet/Delta: This routes the Delta signal to a sidechain channel.
                   Output: FX on channel 1+2, Delta on channel (in channel).
                   This allows further processing of the Delta signal on different channels.
                   Can be used for nice pumping effects in conjunction with the FX signal,
                   or use it for parameter modulation,
                   or just add some FX (like a Reverb or a Delay) to the sidechain channel.
                   Gives some very interesting results.
5: Wet/Dry: This routes the unprocessed signal to a sidechain channel.
                 Output: FX on channel 1+2, unprocessed signal on channel (in channel).
                 Good for NY compression. (or whatever...)

You can send the sidechain signal to another track (Set 'out channel' to: same as in channel)
or you can just route the output to 1+2 on that same track (Set 'out channel' to: all to 1+2)
(In the 'all to 1+2' -Mode, the track must have at least four channels !!!)

When in 'Delta' -Mode,
avoid using auto make-up in the FX plugins,
also don't use any gain sliders in the FX plugins...
*/

slider1:1<0,4,1{1:  dry 1+2,2:  wet 1+2,3:  delta 1+2,4:  wet 1+2 / delta (in channel),5:  wet 1+2 / dry (in channel)}>mode
slider2:0<-60,12,0.1>wet volume (dB)
slider3:0<-60,12,0.1>delta/dry volume (dB)
slider5:1<0,31,1{-------,3+4,5+6,7+8,9+10,11+12,13+14,15+16,17+18,19+20,21+22,23+24,25+26,27+28,29+30,31+32,33+34,35+36,37+38,39+40,41+42,43+44,45+46,47+48,49+50,51+52,53+54,55+56,57+58,59+60,61+62,63+64}>in channel
slider6:1<0,1,1{same as in channel,all to 1+2}>out channel

@init
scale = log(10)*0.05;

@slider
adj1 = slider2 <= -60.0 ? 0.0 : exp(slider2*scale);
adj2 = slider3 <= -60.0 ? 0.0 : exp(slider3*scale);

channel = slider5*2;
in = channel;
in2 = in+1;

@sample
os0=spl(in);
os1=spl(in2);

s0=spl0*adj1;
s1=spl1*adj1;

delta0=(spl0-os0)*adj2;
delta1=(spl1-os1)*adj2;

noFX0=os0*adj2;
noFX1=os1*adj2;

slider1 == 0 ? ( // dry
spl0=noFX0;
spl1=noFX1;
spl(in)=0;
spl(in2)=0;
);

slider1 == 1 ? ( // wet
spl0=s0;
spl1=s1;
spl(in)=0;
spl(in2)=0;
);

slider1 == 2 ? ( // delta
spl0=delta0;
spl1=delta1;
spl(in)=0;
spl(in2)=0;
);

slider1 == 3 ? ( // wet/delta
slider6 == 0 ? ( // to sidechain
spl(in)=delta0;
spl(in2)=delta1;
spl0=s0;
spl1=s1;
);
slider6 == 1 ? ( // to 1+2
spl0=delta0+s0;
spl1=delta1+s1;
spl(in)=0;
spl(in2)=0;
);
);

slider1 == 4 ? ( // wet/dry
slider6 == 0 ? ( // to sidechain
spl(in)=noFX0;
spl(in2)=noFX1;
spl0=s0;
spl1=s1;
);
slider6 == 1 ? ( // to 1+2
spl0=noFX0+s0;
spl1=noFX1+s1;
spl(in)=0;
spl(in2)=0;
);
);
