Godtone (talk | contribs)
Godtone (talk | contribs)
Novation Launchpad Pro MK3 isomorphic keyboard code: cleaning & make bottom buttons usable (interpreted as two halves of a single button)
Line 1,145: Line 1,145:
def transform(midi_note):
def transform(midi_note):
return (midi_note % 10) * x + (midi_note//10 - 1) * y + bottomleftnote
if midi_note < 100:
return (midi_note % 10) * x + (midi_note//10) * y + bottomleftnote
else:
return (midi_note - 100) * x + bottomleftnote
note_state = dict()
note_state = dict()
for k in range(10,99):
key_codes = range(1,109)
for k in key_codes:
note_state[transform(k)] = 0
note_state[transform(k)] = 0
with mido.open_output(launchpad) as col: # apply off colours
with mido.open_output(launchpad) as col: # apply off colours
for k in range(10,99): # for all keycodes...
for k in key_codes:
col.send(mido.Message('note_on', channel=0, note=k, velocity=note_to_col(-transform(k))))
col.send(mido.Message('note_on', channel=0, note=k, velocity=note_to_col(-transform(k))))
# transform the launchpad pro mk3's midi input (mi) into custom midi output (mo)
# transform the launchpad pro mk3's midi input (mi) into custom midi output (mo)
Line 1,167: Line 1,171:
k = 0
k = 0
note_vel = note_vel if note_vel > 4 else 0
note_vel = note_vel if note_vel > 4 else 0
if k>=10 and k<99:
if k:
midi_note = transform(k)
midi_note = transform(k)
if note_vel: # if we're pressing a key
if note_vel: # if we're pressing a key
Line 1,176: Line 1,180:
mo.send(to_send) # turn off equivalent midi note
mo.send(to_send) # turn off equivalent midi note
else: # light all equivalent keys
else: # light all equivalent keys
for k in range(10,99): # for all keycodes...
for k in key_codes:
if transform(k)==midi_note: # if equivalent... light key
if transform(k)==midi_note: # if equivalent... light key
col.send(mido.Message('note_on', channel=0, note=k, velocity=note_to_col(midi_note)))
col.send(mido.Message('note_on', channel=0, note=k, velocity=note_to_col(midi_note)))
Line 1,189: Line 1,193:
print(to_send)
print(to_send)
mo.send(to_send) # turn off equivalent midi note
mo.send(to_send) # turn off equivalent midi note
for k in range(10,99): # for all keycodes...
for k in key_codes:
if transform(k)==midi_note: # if equivalent... unlight key
if transform(k)==midi_note: # if equivalent... unlight key
col.send(mido.Message('note_on', channel=0, note=k, velocity=note_to_col(-midi_note)))
col.send(mido.Message('note_on', channel=0, note=k, velocity=note_to_col(-midi_note)))


</syntaxhighlight>
</syntaxhighlight>