glennyg
2014-03-06 16:43:15
I wanted to recreate the common hardware feature found on multi-timbral keyboards where you can switch midi receive/local on and off for a sound, for instance to layer strings over a piano. The hardware waits for note off or velocity=0 before turning off midi receive so you don't get hung notes even if you turn the switch off while holding notes.
I'm new at this so it took a while and the first attempt worked but wasted polyphony. This one does everything I want.
Feel free to suggest refinements. I only defined a global value for switch=on for tracking purposes. It makes it easy to see if I get offsets wrong in the re-channelling versions of the translator.
UPDATE! This is several lines shorter and doesn't use any Labels. Also previous version allowed sustain pedal to cause hung notes.
Controller is transmitting on Ch1. Switches assigned to CC102, CC103, CC104 etc.
Check for CC message > check if matches the controller switch > set global variable value.
Check for sustain=off message, always send it.
If controller is sending note-on-velocity=0 instead of note off, make it a note off message (saves polyphony) and always send it.
Check for note off message > always send it.
If flag shows switch is off, don't transmit any other message types (i.e. transmits note off and sustain off messages only).
----------
Translator 1
(for control of Ch1)
Incoming Message: pp qq vv
Rules:
if pp==176 then oo=pp+qq
if oo==278 then oo=oo+vv
if oo==278 then ga=1
if oo==405 then ga=2
if oo==240 then oo=oo+vv
if oo==240 then exit rules, execute Outgoing Action
if pp==144 then ww=pp+vv
if ww==pp then pp=pp-16
if pp<144 then exit rules, execute Outgoing Action
if ga==1 then exit rules, skip Outgoing Action
exit rules, execute Outgoing Action
Outgoing Message: pp qq vv
-----------
Translator 2
(For control of Ch2. Note the offsets from Translator 1. Apply on duplicate Translators for up to 16 channels)
Incoming Message: pp qq vv
Rules:
pp=pp+1
if pp==177 then oo=pp+qq
if oo==280 then oo=oo+vv
if oo==280 then gb=1
if oo==407 then gb=2
if oo==241 then oo=oo+vv
if oo==241 then exit rules, execute Outgoing Action
if pp==145 then ww=pp+vv
if ww==pp then pp=pp-16
if pp<144 then exit rules, execute Outgoing Action
if gb==1 then exit rules, skip Outgoing Action
exit rules, execute Outgoing Action
Outgoing Message: pp qq vv
----------
I'm new at this so it took a while and the first attempt worked but wasted polyphony. This one does everything I want.
Feel free to suggest refinements. I only defined a global value for switch=on for tracking purposes. It makes it easy to see if I get offsets wrong in the re-channelling versions of the translator.
UPDATE! This is several lines shorter and doesn't use any Labels. Also previous version allowed sustain pedal to cause hung notes.
Controller is transmitting on Ch1. Switches assigned to CC102, CC103, CC104 etc.
Check for CC message > check if matches the controller switch > set global variable value.
Check for sustain=off message, always send it.
If controller is sending note-on-velocity=0 instead of note off, make it a note off message (saves polyphony) and always send it.
Check for note off message > always send it.
If flag shows switch is off, don't transmit any other message types (i.e. transmits note off and sustain off messages only).
----------
Translator 1
(for control of Ch1)
Incoming Message: pp qq vv
Rules:
if pp==176 then oo=pp+qq
if oo==278 then oo=oo+vv
if oo==278 then ga=1
if oo==405 then ga=2
if oo==240 then oo=oo+vv
if oo==240 then exit rules, execute Outgoing Action
if pp==144 then ww=pp+vv
if ww==pp then pp=pp-16
if pp<144 then exit rules, execute Outgoing Action
if ga==1 then exit rules, skip Outgoing Action
exit rules, execute Outgoing Action
Outgoing Message: pp qq vv
-----------
Translator 2
(For control of Ch2. Note the offsets from Translator 1. Apply on duplicate Translators for up to 16 channels)
Incoming Message: pp qq vv
Rules:
pp=pp+1
if pp==177 then oo=pp+qq
if oo==280 then oo=oo+vv
if oo==280 then gb=1
if oo==407 then gb=2
if oo==241 then oo=oo+vv
if oo==241 then exit rules, execute Outgoing Action
if pp==145 then ww=pp+vv
if ww==pp then pp=pp-16
if pp<144 then exit rules, execute Outgoing Action
if gb==1 then exit rules, skip Outgoing Action
exit rules, execute Outgoing Action
Outgoing Message: pp qq vv
----------