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

FX = compressor,limiter,eq or gate (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: You will simply hear the FX output signal. Output is channel 1+2.
2: You will only hear the delta signal. Output is channel 1+2.
    delta=the signal before the FX subtracted from the signal after the FX.
    This allows finetuning of a compressor or a gate
    as you will hear only the processed signal.
3: The FX is bypassed. Output is 1+2.
    Good for comparison.
4: This routes the delta signal to a sidechain.
    Output is FX 1+2, delta (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 for parameter modulation,
    or just add some fx (like a reverb or a delay) to the sidechain channel.
    Gives some very interesting results.
5: This routes the unprocessed signal to a sidechain.
    Output is FX 1+2, unprocessed signal (in channel).
    Good for NY compression. (or whatever)

You can send the sidechain signal to another track
or just use one track. (Set 'out channel' to: all to 1+2)

Avoid using auto make-up in compressors
when setting the plugin to "delta" mode.
*/

slider1:0<0,4,1{1:  FX output 1+2,2:  delta 1+2,3:  unprocessed 1+2,4:  FX output 1+2 / delta (in channel),5:  FX output 1+2 / unprocessed (in channel)}>mode
slider2:0<-60,12,0.1>FX volume (dB)
slider3:0<-60,12,0.1>delta/unprocessed 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:0<0,1,1{original,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 ? (
spl0=s0;
spl1=s1;
spl(in)=0;
spl(in2)=0;
);

slider1 == 1 ? (
spl0=delta0;
spl1=delta1;
spl(in)=0;
spl(in2)=0;
);

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

slider1 == 3 ? (
slider6 == 0 ? (
spl(in)=delta0;
spl(in2)=delta1;
spl0=s0;
spl1=s1;
);
slider6 == 1 ? (
spl0=delta0+s0;
spl1=delta1+s1;
spl(in)=0;
spl(in2)=0;
);
);

slider1 == 4 ? (
slider6 == 0 ? (
spl(in)=noFX0;
spl(in2)=noFX1;
spl0=s0;
spl1=s1;
);
slider6 == 1 ? (
spl0=noFX0+s0;
spl1=noFX1+s1;
spl(in)=0;
spl(in2)=0;
);
);
