Godtone
Joined 17 December 2020
m →Novation Launchpad Pro MK3 isomorphic keyboard code: typo & clarification of wording |
→Novation Launchpad Pro MK3 isomorphic keyboard code: imperfect fix for making half-buttons indistinct (but making the fix perfect would be annoyingly complex for me) |
||
| Line 1,131: | Line 1,131: | ||
rb17v2 = [ rb29[round( k/17*29+0.4 )%29] for k in range(17)] | rb17v2 = [ rb29[round( k/17*29+0.4 )%29] for k in range(17)] | ||
rb19 = [ rb29[round( k/19*29+0.4 )%29] for k in range(19)] | rb19 = [ rb29[round( k/19*29+0.4 )%29] for k in range(19)] | ||
def iso(x=5, y=1, note_to_col = lambda n: 1 if n>0 else 0, bottomleftnote=10, vel=102, half=40): | def iso(x=5, y=1, note_to_col = lambda n: 1 if n>0 else 0, bottomleftnote=10, vel=102, half=40, distinct_half_buttons=True): | ||
colmap = note_to_col | colmap = note_to_col | ||
if type(note_to_col)==list: | if type(note_to_col)==list: | ||
| Line 1,162: | Line 1,162: | ||
k = 0 # what key is being pressed | k = 0 # what key is being pressed | ||
note_vel = 0 | note_vel = 0 | ||
is_half_button = False | |||
if 'control' in str(msg): | if 'control' in str(msg): | ||
k = msg.control | k = msg.control | ||
note_vel = vel if msg.value else 0 | note_vel = vel if msg.value else 0 | ||
is_half_button = msg.control > 100 or msg.control < 10 | |||
elif 'note' in str(msg): | elif 'note' in str(msg): | ||
k = msg.note | k = msg.note | ||
| Line 1,177: | Line 1,179: | ||
to_send = mido.Message('note_on', channel=0, note=midi_note, velocity=0) | to_send = mido.Message('note_on', channel=0, note=midi_note, velocity=0) | ||
print(to_send) | print(to_send) | ||
mo.send(to_send) # turn off equivalent midi note before repressing | if not is_half_button or distinct_half_buttons: | ||
mo.send(to_send) # turn off equivalent midi note before repressing | |||
else: # light all equivalent keys | else: # light all equivalent keys | ||
for k in key_codes: | for k in key_codes: | ||
| Line 1,184: | Line 1,187: | ||
to_send = mido.Message('note_on', channel=0, note=midi_note, velocity=note_vel) | to_send = mido.Message('note_on', channel=0, note=midi_note, velocity=note_vel) | ||
print(to_send) | print(to_send) | ||
mo.send(to_send) # turn on equivalent midi note | if not is_half_button or note_state[transform(k)]==0 or distinct_half_buttons: | ||
mo.send(to_send) # turn on equivalent midi note | |||
note_state[midi_note] += 1 | note_state[midi_note] += 1 | ||
elif note_state[midi_note]: # if we're releasing a key and there are equivalent keys held | elif note_state[midi_note]: # if we're releasing a key and there are equivalent keys held | ||
| Line 1,195: | Line 1,199: | ||
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> | ||