desc: MIDI Route PC To Channel version: 1.0 changelog: init author: zaibuyidao reference: https://forum.cockos.com/showpost.php?p=1543389&postcount=9 about: listens for Program Change messages sets the MIDI channel to 1 ... 16 slider1:0<0,127,1>Program Change slider2:1<1,16,1>Channel in_pin:none out_pin:none @init note_on = 9; note_off = 8; // remember current notes start_ons = 1024; note_ons = start_ons; end_ons = note_ons + 128; memset(start_ons, -1, 128); @slider @sample while ( midirecv(offset, msg1, msg2, msg3) ? ( statusHi = (msg1 / 16) | 0; statusLo = msg1 - (statusHi * 16); msg = (msg1 / 16) | 0; msg_num = msg2; msg_val = msg3; pc_received = msg == 12; bs_received = msg == 11 && (msg_num == 0 || msg_num ==32); pc_received ? ( slider1 = msg_num; msg_num > 0 ? msg_num -=1; channel_route = msg_num % 16; // constrain to 0 ... 15 slider2 = channel_route + 1; msg1 = $xc0 + channel_route; // msg = 0; // don't passthrough ); bs_received ? ( msg1 = $xb0 + channel_route; msg = 0; // don't passthrough ); msg == note_off || (msg == note_on && msg_val == 0) ? ( msg1 = msg * 16 + note_ons[msg_num]; ) : msg1 = msg * 16 + channel_route; msg == note_on && msg_val > 0 ? ( note_ons[msg_num] = channel_route; ); msg > 0 ? midisend(offset, msg1, msg2, msg3); ); );