This is a simple script which lets midi notes control which stereo pair the input signal is sent to. It uses only the pitch class, and as written only supports 4 output pairs, but it is trivial to add support for more. At present I just use `spl(X) = 0` to clear the output channels rather than a for loop. ``` desc:Switch stereo audio channels by midi slider1:gain_db=0<-150,12,1>gain (dB) in_pin:left input in_pin:right input out_pin:left output1 out_pin:right output1 out_pin:left output2 out_pin:right output2 out_pin:left output3 out_pin:right output3 out_pin:left output4 out_pin:right output4 @init opair = 0; @block while(midirecv(offset,msg1,msg2,msg3)) ( status = msg1; channel = msg1 & 0xF; cmd = msg1 >> 4; ( cmd == 0x9 && channel == 0xF ) ? ( opair = msg2 & 3; ); midisend(offset,msg1,msg2,msg3); ;) @sample x0 = spl0; x1 = spl1; spl(0) = 0; spl(1) = 0; spl(2) = 0; spl(3) = 0; spl(4) = 0; spl(5) = 0; spl(6) = 0; spl(7) = 0; spl(2*opair) = x0; spl(2*opair+1) = x1; ``` # Output based on note held Again this does four channels for now, but trivial to modify. This time, the plugin outputs to *all* channels corresponding to which notes are held. C == channels 1/2, C# == channels 3/4, etc. ``` desc:JDA Switch stereo audio channels on/off by midi slider1:gain_db=0<-150,12,1>gain (dB) in_pin:left input in_pin:right input out_pin:left output1 out_pin:right output1 out_pin:left output2 out_pin:right output2 out_pin:left output3 out_pin:right output3 out_pin:left output4 out_pin:right output4 @init channel_status_base = 100; @block while(midirecv(offset,msg1,msg2,msg3)) ( status = msg1; channel = msg1 & 0xF; cmd = msg1 >> 4; ( channel == 0xF ) ? ( pc = msg2 % 12; ( cmd == 0x9 && msg3 > 0 ) ? ( channel_status_base[pc] = 1; ) : ( ( cmd == 0x9 && msg3 == 0 ) || ( cmd == 0x8 ) ) ? ( channel_status_base[pc] = 0; ); ); midisend(offset,msg1,msg2,msg3); ); @sample a0 = channel_status_base[0]; a1 = channel_status_base[1]; a2 = channel_status_base[2]; a3 = channel_status_base[3]; c = channel_status_base[2] > 0; x0 = spl(0); x1 = spl(1); loop( i=0; 4, s = channel_status_base[i]; spl(2*i) = s ? x0 : 0; spl(2*i+1) = s ? x1 : 0; i += 1; ); ``` # Later Ideas * Make version with 12 output pairs.