Skip to content

Commit 02692ea

Browse files
committed
Novation_ZeRO_SL_MkII.py: send transport commands via MIDI control pedal
1 parent 7f2a4fc commit 02692ea

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

src/PythonMcu/Hardware/Novation_ZeRO_SL_MkII.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class Novation_ZeRO_SL_MkII(MidiControllerTemplate):
5858
_MIDI_CC_FADERS = 0x10
5959
_MIDI_CC_ENCODERS = 0x38
6060
_MIDI_CC_KNOBS = 0x08
61+
_MIDI_CC_CONTROL_PEDAL = 0x40
6162

6263
_MIDI_CC_BUTTON_BANK_UP = 0x58
6364
_MIDI_CC_BUTTON_BANK_DOWN = 0x59
@@ -262,6 +263,8 @@ def receive_midi(self, status, message):
262263
'self.interconnector.move_vpot_raw(self._MIDI_DEVICE_CHANNEL, 6, %d)',
263264
self._MIDI_CC_ENCODERS + 7:
264265
'self.interconnector.move_vpot_raw(self._MIDI_DEVICE_CHANNEL, 7, %d)',
266+
self._MIDI_CC_CONTROL_PEDAL:
267+
'self.on_control_pedal(%d & 0x01)',
265268
self._MIDI_CC_BUTTON_BANK_UP:
266269
'self._change_mode_edit(%d & 0x01)',
267270
self._MIDI_CC_BUTTON_BANK_DOWN:
@@ -496,6 +499,17 @@ def all_leds_off(self):
496499
self.send_midi_control_change(self._MIDI_CC_CLEAR_ALL_LEDS, 0x00)
497500

498501

502+
# --- pedal handling ---
503+
504+
def on_control_pedal(self, status):
505+
if self.interconnector.is_playing():
506+
mcu_command = 'stop'
507+
else:
508+
mcu_command = 'play'
509+
510+
self.interconnector.keypress_unregistered(mcu_command, status)
511+
512+
499513
# --- mode handling ---
500514

501515
def _set_menu_string(self, menu_strings):

src/PythonMcu/McuInterconnector/McuInterconnector.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def __init__(self, mcu_model_id, mcu_connection, \
161161
mcu_midi_input, mcu_midi_output, \
162162
hardware_controller_class, controller_midi_input, \
163163
controller_midi_output, callback_log):
164+
self._play_status = False
164165
self._callback_log = callback_log
165166

166167
eval_controller_init = \
@@ -268,31 +269,40 @@ def withdraw_all_controls(self):
268269

269270
def keypress(self, internal_id, status):
270271
if internal_id in self._led__hardware_to_mcu:
271-
command = 'self._mackie_host_control.keypress_%s(%d)' % \
272-
(self._led__hardware_to_mcu[internal_id], status)
273-
274-
eval(command)
272+
mcu_command = self._led__hardware_to_mcu[internal_id]
273+
self.keypress_unregistered(mcu_command, status)
275274
return True
276275
else:
277276
return False
278277

279278

279+
def keypress_unregistered(self, mcu_command, status):
280+
command = 'self._mackie_host_control.keypress_%s(%d)' % \
281+
(mcu_command, status)
282+
eval(command)
283+
284+
280285
def _set_led(self, mcu_command, status):
281286
if self._led__mcu_to_hardware[mcu_command]['value'] != status:
282287
self._led__mcu_to_hardware[mcu_command]['value'] = status
283288

284-
if self._led__mcu_to_hardware[mcu_command]['midi_switch'] \
285-
is not None:
289+
if type(self._led__mcu_to_hardware[mcu_command]['midi_switch']) != \
290+
types.NoneType:
286291
self._update_led(mcu_command)
287292

288293

289294
def _update_led(self, mcu_command):
290-
if self._led__mcu_to_hardware[mcu_command]['midi_switch'] is not None:
295+
if type(self._led__mcu_to_hardware[mcu_command]['midi_switch']) != \
296+
types.NoneType:
291297
status = self._led__mcu_to_hardware[mcu_command]['value']
292298
self._hardware_controller.set_led( \
293299
self._led__mcu_to_hardware[mcu_command]['midi_led'], status)
294300

295301

302+
def is_playing(self):
303+
return self._play_status
304+
305+
296306
# --- hardware controller commands ---
297307

298308
def has_display_7seg(self):
@@ -496,6 +506,11 @@ def set_led_stop(self, status):
496506

497507

498508
def set_led_play(self, status):
509+
if status:
510+
self._play_status = True
511+
else:
512+
self._play_status = False
513+
499514
self._set_led('play', status)
500515

501516

0 commit comments

Comments
 (0)