/*******************************************************************************
*  Copyright 2007 - 2011, Philip S. Considine                                  *
*  This program is free software: you can redistribute it and/or modify        *
*  it under the terms of the GNU General Public License as published by        *
*  the Free Software Foundation, either version 3 of the License, or           *
*  (at your option) any later version.                                         *
*                                                                              *
*  This program is distributed in the hope that it will be useful,             *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                *
*  GNU General Public License (http://www.gnu.org/licenses/)for more details.  *
*******************************************************************************/

desc:8 Input (4 stereo), 2 Bus X-Fade Thing

slider1:3<0,3,1{Off,A,B,A+B}>Dest 1+2
slider2:0<0,3,1{Off,A,B,A+B}>Dest 3+4
slider3:0<0,3,1{Off,A,B,A+B}>Dest 5+6
slider4:0<0,3,1{Off,A,B,A+B}>Dest 7+8
slider5:0.5<0,1>Mix A<->B

////////////////////////////////////////////////////////////////////////////////
@slider
dest12 = slider1;
dest34 = slider2;
dest56 = slider3;
dest78 = slider4;

slider5 = min(max(slider5, 0), 1);

// Calculate the gain multipliers
mixA = 1 - slider5;
mixB = slider5;
ch12 = (dest12 == 1 || dest12 == 3 ? 1:0) * mixA + (dest12 == 2 || dest12 == 3 ? 1:0) * mixB;
ch34 = (dest34 == 1 || dest34 == 3 ? 1:0) * mixA + (dest34 == 2 || dest34 == 3 ? 1:0) * mixB;
ch56 = (dest56 == 1 || dest56 == 3 ? 1:0) * mixA + (dest56 == 2 || dest56 == 3 ? 1:0) * mixB;
ch78 = (dest78 == 1 || dest78 == 3 ? 1:0) * mixA + (dest78 == 2 || dest78 == 3 ? 1:0) * mixB;

////////////////////////////////////////////////////////////////////////////////
@sample
spl0 = spl0 * ch12 + spl2 * ch34 + spl4 * ch56 + spl6 * ch78;
spl1 = spl1 * ch12 + spl3 * ch34 + spl5 * ch56 + spl7 * ch78;
