I lifted the mididings python code from the previous post & added a jack-rt backend to it. You'll need to have mididings installed.
Paste this into a file and save as a python script ex. "latch-on-off.py" and run with python latch-on-off.py.
Then route your keyboard controller through this MIDI processor and out to your softsynth.
A warning is displayed but oh well, it seems to work.
Code: Select all
from mididings import *
from mididings.event import *
config(
backend='jack-rt',
client_name='Latch On Off',
)
buttonState = [0] * 128;
####################################################################################################
# buttonCtrl: Toggle outgoing CC event value when the incoming value is non-zero
####################################################################################################
#
# Convert the momentary on/off buttons to mode toggle events when the button press occurs
#
def buttonCtrl (event):
button = event.ctrl;
value = event.value;
if (value != 0):
state = buttonState [button] = value if (buttonState [button] == 0) else 0;
event = CtrlEvent (event.port, event.channel, button, state);
print (" - Ctrl (%d, %d) => Ctrl (%d, %d)" % (button, value, button, state));
return event;
else:
print (" - Ctrl (%d, %d) => *IGNORED*" % (button, value));
return None;
####################################################################################################
# midiCtrl: Route the incoming MIDI messages to the event filter
####################################################################################################
def midiCtrl (event):
button = event.ctrl;
if (button >= 51 and button <= 59): return (buttonCtrl (event));
elif (button == 104 or button == 105): return (buttonCtrl (event));
elif (button >= 112 and button <= 117): return (buttonCtrl (event));
return event;
run (
Filter (CTRL) % Process (midiCtrl)
)