Skip to content

Commit 0515477

Browse files
committed
LinnStrument 200 support
1 parent 418803b commit 0515477

File tree

2 files changed

+107
-11
lines changed

2 files changed

+107
-11
lines changed

midimech.py

+104-11
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,28 @@ def reset_light(self, x, y, reset_red=True):
191191
self.set_light(x, y, light_col)
192192
self.red_lights[y][x] = False
193193

194+
def reset_launchpad_light(self, x, y):
195+
note = self.get_note_index(x, 8-y-1) % 12
196+
# if self.is_split():
197+
# split_chan = self.channel_from_split(self.board_h - y - 1, x)
198+
# if split_chan:
199+
# light_col = self.options.split_lights[note]
200+
# else:
201+
light_col = self.options.lights[note]
202+
# else:
203+
# light_col = self.options.lights[note]
204+
self.set_launchpad_light(x, y, light_col)
205+
194206
def set_red_light(self, x, y, state=True):
195207
self.red_lights[y][x] = state
196208
if self.launchpad:
197209
lp_col = ivec3(127, 0, 0)
198210
if state:
199-
self.launchpad.LedCtrlXY(x, y+1, lp_col[0], lp_col[1], lp_col[2])
211+
self.launchpad.LedCtrlXY(x, y, lp_col[0], lp_col[1], lp_col[2])
212+
213+
def set_launchpad_light(self, x, y, color):
214+
col = COLOR_CODES[color]
215+
self.launchpad.LedCtrlXY(x, 8-y, col[0], col[1], col[2])
200216

201217
def setup_lights(self):
202218
for y in range(self.board_h):
@@ -380,8 +396,6 @@ def next_free_note(self):
380396
return None
381397

382398
def note_on(self, data, timestamp, width=None, curve=True, no_overlap=None):
383-
if width is None:
384-
width = self.board_w // 2 if self.options.hardware_split else self.board_w
385399
if no_overlap is None:
386400
no_overlap = self.options.no_overlap
387401
d0 = data[0]
@@ -394,14 +408,47 @@ def note_on(self, data, timestamp, width=None, curve=True, no_overlap=None):
394408
row = None
395409
col = None
396410

411+
within_hardware_split = False
412+
if width is None:
413+
if self.options.hardware_split:
414+
if self.board_w == 25: # 200
415+
left_width = 11
416+
right_width = 14
417+
if ch >= 8:
418+
width = right_width
419+
within_hardware_split = True
420+
else:
421+
width = left_width
422+
else:
423+
left_width = 8
424+
right_width = 8
425+
if ch >= 8:
426+
width = right_width
427+
within_hardware_split = True
428+
else:
429+
width = left_width
430+
else:
431+
width = self.board_w
432+
# else: # 128
433+
# width = 8 if self.options.hardware_split else 16
434+
435+
if self.options.debug:
436+
print("MIDI:", data)
437+
print("Message:", msg)
438+
print("Channel:", ch)
439+
print("---")
440+
397441
if no_overlap:
398442
row = data[1] // width
399443
col = data[1] % width
400-
data[1] = data[1] % width + 30 + 2.5 * row
444+
if within_hardware_split:
445+
data[1] += left_width
446+
data[1] = col + 30 + 2.5 * row
401447
data[1] *= 2
402448
data[1] = int(data[1])
403-
if self.options.hardware_split and ch >= 8:
404-
data[1] += width * 2
449+
if within_hardware_split:
450+
data[1] += left_width * 2
451+
# print(data[1])
405452
else:
406453
row = ch % 8
407454
col = ch // 8
@@ -463,8 +510,7 @@ def note_on(self, data, timestamp, width=None, curve=True, no_overlap=None):
463510
def note_off(self, data, timestamp, width=None, no_overlap=None):
464511
if no_overlap is None:
465512
no_overlap = self.options.no_overlap
466-
if width is None:
467-
width = self.board_w // 2 if self.options.hardware_split else self.board_w
513+
468514
d0 = data[0]
469515
# print(data)
470516
ch = d0 & 0x0F
@@ -473,17 +519,61 @@ def note_off(self, data, timestamp, width=None, no_overlap=None):
473519
data[0] = d0 & 0xF0 # send all to channel 0 if enabled
474520
row = None
475521
col = None
522+
523+
# if width is None:
524+
# if self.board_w == 25: # 200
525+
# width = 11 if self.options.hardware_split else 25
526+
# else: # 128
527+
# width = 8 if self.options.hardware_split else 16
528+
# if width is None:
529+
# left_width = 5
530+
# right_width = 11
531+
# width = left_width if ch < 8 else right_width
532+
533+
within_hardware_split = False
534+
if width is None:
535+
if self.options.hardware_split:
536+
if self.board_w == 25: # 200
537+
left_width = 11
538+
right_width = 14
539+
if ch >= 8:
540+
width = right_width
541+
within_hardware_split = True
542+
else:
543+
width = left_width
544+
else:
545+
left_width = 8
546+
right_width = 8
547+
if ch >= 8:
548+
width = right_width
549+
within_hardware_split = True
550+
else:
551+
width = left_width
552+
else:
553+
width = self.board_w
554+
476555
if not no_overlap:
477556
row = ch % 8
478557
col = ch // 8
479558
if no_overlap:
559+
# row and col within the current split
560+
# row = data[1] // width
561+
# col = data[1] % width
562+
# print(data[1])
563+
# # data[1] = data[1] % width + 30 + 2.5 * row
564+
# data[1] *= 2
565+
# data[1] = int(data[1])
566+
# if self.options.hardware_split and ch >= 8:
567+
# data[1] += self.board_w
480568
row = data[1] // width
481569
col = data[1] % width
482-
data[1] = data[1] % width + 30 + 2.5 * row
570+
if within_hardware_split:
571+
data[1] += left_width
572+
data[1] = col + 30 + 2.5 * row
483573
data[1] *= 2
484574
data[1] = int(data[1])
485-
if self.options.hardware_split and ch >= 8:
486-
data[1] += width * 2
575+
if within_hardware_split:
576+
data[1] += left_width * 2
487577
else:
488578
data[1] *= 2
489579
try:
@@ -612,12 +702,14 @@ def cb_launchpad_in(self, event, timestamp=0):
612702
y = 8 - event[1]
613703
if 0 <= x < 8 and 0 <= y < 8:
614704
note = y * 8 + x
705+
self.reset_launchpad_light(x, y)
615706
self.note_off([128, note, event[2]], timestamp, width=8, no_overlap=True)
616707
else: # note on
617708
x = event[0]
618709
y = 8 - event[1]
619710
if 0 <= x < 8 and 0 <= y < 8:
620711
note = y * 8 + x
712+
self.set_launchpad_light(x, y, 1) # red
621713
self.note_on([144, note, event[2]], timestamp, width=8, no_overlap=True)
622714
else:
623715
if x == 2:
@@ -793,6 +885,7 @@ def __init__(self):
793885

794886
self.options.launchpad = get_option(opts, 'launchpad', True)
795887
self.options.experimental = get_option(opts, 'experimental', False)
888+
self.options.debug = get_option(opts, 'debug', False)
796889

797890
# simulator keys
798891
self.keys = {}

scripts/build_windows_package.ps1

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cd ..
2+
python -m PyInstaller --onefile midimech.py
3+
cd scripts

0 commit comments

Comments
 (0)