As promised my changes to the python-files to make all MIDI CC’s available:
All files are in the directory /root/ETC_Mother/.
1.) midi.py
I kept the original definition of the variable “cc” and added a new variable midi_cc. New code is marked with “###”
[...]
# channel messages
if ( (msg_channel == (etc.midi_ch - 1)) or (etc.midi_ch == 0)) :
#
# CC original
if (msg_type == 0xB) :
etc.new_midi = True
for i in range(0,16) :
if (midi_msg[1] == 21 + i) :
cc = midi_msg[2]
if cc != cc_last[i] :
etc.cc_override_knob(i, float(cc) / 127)
cc_last[i] = cc
# CC new version ###
if (msg_type == 0xB) : ###
etc.midi_new = True ###
etc.midi_cc[midi_msg[1]] = midi_msg[2] ###
#
# note OFF
if (msg_type == 0x8) :
[...]
2.) etc_system.py:
All the new code marked by an “###” at the end of the line
[...]
# midi stuff (CC gets updated into knobs
midi_notes = [0] * 128
midi_notes_last = [0] * 128
midi_note_new = False
midi_cc = [0] * 128 ###
midi_cc_last = [0] * 128 ###
midi_cc_new = False ###
ctrl = 0
midi_pgm = 0
[...]
# check for new notes
for i in range(0, 128):
if self.midi_notes[i] > 0 and self.midi_notes_last[i] == 0:
self.midi_note_new = True
# check for new CCs ###
for i in range(0, 128): ###
if self.midi_cc[i] != self.midi_cc_last[i] : ###
print ("CC" + str(i) + "; value: " + str(self.midi_cc[i])) ###
self.midi_cc_new = True ###
[...]
def clear_flags(self):
self.new_midi = False
self.audio_trig = False
self.run_setup = False
self.screengrab_flag = False
self.midi_note_new = False
for i in range(0, 128):
self.midi_notes_last[i] = self.midi_notes[i]
for i in range(0, 128): ###
self.midi_cc_last[i] = self.midi_cc[i] ###
and finally:
3.) main.py
[...]
midi_led_flashing = False
#
osd_is = False
#
midi_cc_last = [0] * 128
#
while 1:
# read keyboard keys to as buttons:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
#left cursor selects previous mode
if event.key == pygame.K_LEFT: etc.prev_mode()
#right cursor selects previous mode
if event.key == pygame.K_RIGHT: etc.next_mode()
#ESC-key exits the program
if event.key == pygame.K_ESCAPE: sys.exit()
#the "t"-key and the period key act as trigger button
if event.key == pygame.K_t: etc.update_trig_button(1)
if event.key == pygame.K_PERIOD: etc.update_trig_button(1)
#the "p"-key toggles the OSD-display
if event.key == pygame.K_p:
if (osd_is) :
etc.set_osd(False)
osd_is = False
else :
etc.set_osd(True)
osd_is = True
#the "r"-key reloads the mode.
#this is helpful if you are logged in with SSH and edit
#the mode on the USB-stick with an editor
if event.key == pygame.K_r: etc.reload_mode()
#
#the "p"-key toggles the OSD-display
if event.key == pygame.K_c:
if (etc.auto_clear) : etc.auto_clear = False
else : etc.auto_clear = True
#
#Korg Nanopad sends CC's from the buttons.
#next mode by FFWD-Button
m=44
if midi_cc_last[m] == 0:
if etc.midi_cc[m] == 127:
etc.next_mode()
midi_cc_last[m] = etc.midi_cc[m]
if etc.midi_cc[m] == 0:
midi_cc_last[m] = 0
#
#previous mode by REW-Button
m=43
if midi_cc_last[m] == 0:
if etc.midi_cc[m] == 127:
etc.prev_mode()
midi_cc_last[m] = etc.midi_cc[m]
if etc.midi_cc[m] == 0:
midi_cc_last[m] = 0
#
#toggle the autoclear by the STOP button.
m=42
if midi_cc_last[m] == 0:
if etc.midi_cc[m] == 127:
if (etc.auto_clear) : etc.auto_clear = False
else : etc.auto_clear = True
midi_cc_last[m] = etc.midi_cc[m]
if etc.midi_cc[m] == 0:
#
# check for OSC
...