He he, there was a mistake in there (permanently changing the "channel" variable when just retrieving a channel for one note-off).
Here's the new @block section...
Code:
@block
while (
midirecv(offset,msg1,msg23) ? (
// Extract note and status value
note = msg23&$x7F;
statusLo = (msg1/16)|0;
status = msg1&$xF0;
//If we recieve a note on message
statusLo ==9 ? (
note == ks1 ? channel = 0;
note == ks2 ? channel = 1;
note == ks3 ? channel = 2;
note == ks4 ? channel = 3;
note == ks5 ? channel = 4;
note == ks6 ? channel = 5;
note == ks7 ? channel = 6;
note == ks8 ? channel = 7;
note == ks9 ? channel = 8;
note == ks10 ? channel = 9;
note == ks11 ? channel = 10;
note == ks12 ? channel = 11;
note == ks13 ? channel = 12;
note == ks14 ? channel = 13;
note == ks15 ? channel = 14;
note == ks16 ? channel = 15;
playednotes[note] = channel+1; //add one to the channel so unplayed slots will be zero
);
//If we receive a note off message
statusLo == 8 ? (
//if the slot in is true (>0) it means this note on has been played so retrieve original channel
(playednotes[note]) > 0 ? (
msg1 = status + (playednotes[note])-1;
playednotes[note]=0; //reset the slot
):(
msg1 = status + channel; //else route to new MIDI Channel
);
):(
msg1 = status + channel; //route to new MIDI channel for all non-note off events
);
midisend(offset, msg1, msg23); // Send message on with channel adjustment
);
);