@@ -191,12 +191,28 @@ def reset_light(self, x, y, reset_red=True):
191
191
self .set_light (x , y , light_col )
192
192
self .red_lights [y ][x ] = False
193
193
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
+
194
206
def set_red_light (self , x , y , state = True ):
195
207
self .red_lights [y ][x ] = state
196
208
if self .launchpad :
197
209
lp_col = ivec3 (127 , 0 , 0 )
198
210
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 ])
200
216
201
217
def setup_lights (self ):
202
218
for y in range (self .board_h ):
@@ -380,8 +396,6 @@ def next_free_note(self):
380
396
return None
381
397
382
398
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
385
399
if no_overlap is None :
386
400
no_overlap = self .options .no_overlap
387
401
d0 = data [0 ]
@@ -394,14 +408,47 @@ def note_on(self, data, timestamp, width=None, curve=True, no_overlap=None):
394
408
row = None
395
409
col = None
396
410
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
+
397
441
if no_overlap :
398
442
row = data [1 ] // width
399
443
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
401
447
data [1 ] *= 2
402
448
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])
405
452
else :
406
453
row = ch % 8
407
454
col = ch // 8
@@ -463,8 +510,7 @@ def note_on(self, data, timestamp, width=None, curve=True, no_overlap=None):
463
510
def note_off (self , data , timestamp , width = None , no_overlap = None ):
464
511
if no_overlap is None :
465
512
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
+
468
514
d0 = data [0 ]
469
515
# print(data)
470
516
ch = d0 & 0x0F
@@ -473,17 +519,61 @@ def note_off(self, data, timestamp, width=None, no_overlap=None):
473
519
data [0 ] = d0 & 0xF0 # send all to channel 0 if enabled
474
520
row = None
475
521
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
+
476
555
if not no_overlap :
477
556
row = ch % 8
478
557
col = ch // 8
479
558
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
480
568
row = data [1 ] // width
481
569
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
483
573
data [1 ] *= 2
484
574
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
487
577
else :
488
578
data [1 ] *= 2
489
579
try :
@@ -612,12 +702,14 @@ def cb_launchpad_in(self, event, timestamp=0):
612
702
y = 8 - event [1 ]
613
703
if 0 <= x < 8 and 0 <= y < 8 :
614
704
note = y * 8 + x
705
+ self .reset_launchpad_light (x , y )
615
706
self .note_off ([128 , note , event [2 ]], timestamp , width = 8 , no_overlap = True )
616
707
else : # note on
617
708
x = event [0 ]
618
709
y = 8 - event [1 ]
619
710
if 0 <= x < 8 and 0 <= y < 8 :
620
711
note = y * 8 + x
712
+ self .set_launchpad_light (x , y , 1 ) # red
621
713
self .note_on ([144 , note , event [2 ]], timestamp , width = 8 , no_overlap = True )
622
714
else :
623
715
if x == 2 :
@@ -793,6 +885,7 @@ def __init__(self):
793
885
794
886
self .options .launchpad = get_option (opts , 'launchpad' , True )
795
887
self .options .experimental = get_option (opts , 'experimental' , False )
888
+ self .options .debug = get_option (opts , 'debug' , False )
796
889
797
890
# simulator keys
798
891
self .keys = {}
0 commit comments