@@ -138,9 +138,15 @@ def set_light(self, x, y, col): # col is [1,11], 0 resets
138
138
# self.send_cc(0, 22, 7) # no light
139
139
140
140
def reset_light (self , x , y ):
141
- if not self .options .lights : return
142
141
note = self .get_note_index (x , y ) % 12
143
- light_col = self .options .lights [note ]
142
+ if self .is_split ():
143
+ split_chan = self .channel_from_split (self .board_h - y - 1 , x )
144
+ if split_chan :
145
+ light_col = self .options .split_lights [note ]
146
+ else :
147
+ light_col = self .options .lights [note ]
148
+ else :
149
+ light_col = self .options .lights [note ]
144
150
self .set_light (x , y , light_col )
145
151
self .red_lights [y ][x ] = False
146
152
@@ -151,7 +157,6 @@ def setup_lights(self):
151
157
self .set_light (x , y , 1 )
152
158
else :
153
159
self .reset_light (x , y )
154
-
155
160
156
161
def reset_lights (self ):
157
162
for y in range (self .board_h ):
@@ -188,7 +193,15 @@ def get_note(self, x, y):
188
193
def get_color (self , x , y ):
189
194
# return NOTE_COLORS[get_note_index(x, y)]
190
195
note = self .get_note_index (x , y )
191
- return COLOR_CODES [self .options .lights [note ]]
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
+ return COLOR_CODES [light_col ]
192
205
193
206
def mouse_held (self ):
194
207
return self .mouse_midi != - 1
@@ -423,26 +436,26 @@ def cb_foot(self, data, ts):
423
436
high = self .options .velocity_curve_HIGH
424
437
self .velocity_curve_ = low + val2 * (high - low )
425
438
426
- def save ():
427
- self .cfg = ConfigParser (allow_no_value = True )
428
- general = self .cfg ['general' ] = {}
429
- if self .options .lights :
430
- general ['lights' ] = ',' .join (map (str ,self .options .lights ))
431
- general ['one_channel' ] = self .options .one_channel
432
- general ['velocity_curve' ] = self .options .velocity_curve
433
- general ['min_velocity' ] = self .options .min_velocity
434
- general ['max_velocity' ] = self .options .max_velocity
435
- general ['no_overlap' ] = self .options .no_overlap
436
- general ['hardware_split' ] = self .options .hardware_split
437
- general ['show_lowest_note' ] = self .options .show_lowest_note
438
- general ['midi_out' ] = self .options .midi_out
439
- general ['split_out' ] = self .options .split_out
440
- general ['split' ] = SPLIT
441
- general ['fps' ] = self .options .fps
442
- general ['sustain' ] = SUSTAIN
443
- self .cfg ['general' ] = general
444
- with open ('settings_temp.ini' , 'w' ) as configfile :
445
- self .cfg .write (configfile )
439
+ # def save():
440
+ # self.cfg = ConfigParser(allow_no_value=True)
441
+ # general = self.cfg['general'] = {}
442
+ # if self.options.lights:
443
+ # general['lights'] = ','.join(map(str,self.options.lights))
444
+ # general['one_channel'] = self.options.one_channel
445
+ # general['velocity_curve'] = self.options.velocity_curve
446
+ # general['min_velocity'] = self.options.min_velocity
447
+ # general['max_velocity'] = self.options.max_velocity
448
+ # general['no_overlap'] = self.options.no_overlap
449
+ # general['hardware_split'] = self.options.hardware_split
450
+ # general['show_lowest_note'] = self.options.show_lowest_note
451
+ # general['midi_out'] = self.options.midi_out
452
+ # general['split_out'] = self.options.split_out
453
+ # general['split'] = SPLIT
454
+ # general['fps'] = self.options.fps
455
+ # general['sustain'] = SUSTAIN
456
+ # self.cfg['general'] = general
457
+ # with open('settings_temp.ini', 'w') as configfile:
458
+ # self.cfg.write(configfile)
446
459
447
460
def __init__ (self ):
448
461
@@ -456,11 +469,17 @@ def __init__(self):
456
469
self .options = Options ()
457
470
458
471
default_lights = '4,7,3,7,3,3,7,3,7,3,7,3'
472
+ default_split_lights = '4,7,5,7,5,5,7,5,7,5,7,5'
459
473
460
474
# LIGHT = glm.ivec3(127)
461
475
self .options .lights = get_option (opts ,'lights' ,default_lights )
462
476
if self .options .lights :
463
477
self .options .lights = list (map (lambda x : int (x ), self .options .lights .split (',' )))
478
+
479
+ self .options .split_lights = get_option (opts ,'lights' ,default_split_lights )
480
+ if self .options .split_lights :
481
+ self .options .split_lights = list (map (lambda x : int (x ), self .options .split_lights .split (',' )))
482
+
464
483
self .options .one_channel = get_option (opts ,'one_channel' ,False )
465
484
466
485
# bend the velocity curve, examples: 0.5=sqrt, 1.0=default, 2.0=squared
@@ -746,14 +765,14 @@ def quit(self):
746
765
self .done = True
747
766
748
767
def clear_marks (self , use_lights = False ):
749
- for row in rows :
768
+ y = 0
769
+ for row in self .board :
750
770
x = 0
751
771
for x in range (len (row )):
752
772
idx = self .get_note_index (x , y )
753
773
try :
754
- self .board [y + self . flipped ][x ] = state
774
+ self .board [y ][x ] = False
755
775
except IndexError :
756
- print ("clear_marks: Out of range" )
757
776
pass
758
777
if use_lights :
759
778
if state :
@@ -815,7 +834,7 @@ def resize(self):
815
834
self .dirty_lights = True
816
835
817
836
def channel_from_split (self , row , col ):
818
- if not self .options . split :
837
+ if not self .is_split () :
819
838
return 0
820
839
w = self .board_w
821
840
col += 1 # move start point from C to A#
@@ -825,7 +844,7 @@ def channel_from_split(self, row, col):
825
844
826
845
def is_split (self ):
827
846
# TODO: make this work with hardware overlap (non-mpe)
828
- return self .options .no_overlap and self .options . split and self .split_out
847
+ return self .options .no_overlap and self .split_state and self .split_out
829
848
830
849
def logic (self , dt ):
831
850
@@ -841,6 +860,7 @@ def logic(self, dt):
841
860
try :
842
861
n = self .keys [ev .key ]
843
862
n -= 12
863
+ n += self .octave * 12
844
864
self .mark (n + self .vis_octave * 12 , 1 , True )
845
865
data = [0x90 , n , 127 ]
846
866
# TODO: add split for mouse?
@@ -852,6 +872,7 @@ def logic(self, dt):
852
872
try :
853
873
n = self .keys [ev .key ]
854
874
n -= 12
875
+ n += self .octave * 12
855
876
self .mark (n + self .vis_octave * 12 , 0 , True )
856
877
data = [0x80 , n , 0 ]
857
878
if self .midi_out :
@@ -874,15 +895,19 @@ def logic(self, dt):
874
895
if ev .ui_element == self .btn_octave_down :
875
896
self .octave -= 1
876
897
self .dirty = self .dirty_lights = True
898
+ self .clear_marks (use_lights = False )
877
899
elif ev .ui_element == self .btn_octave_up :
878
900
self .octave += 1
879
901
self .dirty = self .dirty_lights = True
902
+ self .clear_marks (use_lights = False )
880
903
elif ev .ui_element == self .btn_transpose_down :
881
904
self .transpose_board (- 1 )
882
905
self .dirty = self .dirty_lights = True
906
+ self .clear_marks (use_lights = False )
883
907
elif ev .ui_element == self .btn_transpose_up :
884
908
self .transpose_board (1 )
885
909
self .dirty = self .dirty_lights = True
910
+ self .clear_marks (use_lights = False )
886
911
# elif ev.ui_element == self.btn_mode:
887
912
# # TODO: toggle mode
888
913
# self.dirty = True
@@ -901,14 +926,16 @@ def logic(self, dt):
901
926
else :
902
927
self .transpose -= 3
903
928
self .rotated = True
929
+ self .clear_marks (use_lights = False )
904
930
self .dirty = self .dirty_lights = True
905
931
elif ev .ui_element == self .btn_flip :
906
932
self .flipped = not self .flipped
933
+ self .clear_marks (use_lights = False )
907
934
self .dirty = self .dirty_lights = True
908
935
elif ev .ui_element == self .btn_split :
909
936
self .split_state = not self .split_state
910
937
self .btn_split .set_text ("SPLIT: " + ("ON" if self .split_state else "OFF" ))
911
- self .dirty = True
938
+ self .dirty = self . dirty_lights = True
912
939
# elif ev.type == pygame_gui.UI_HORIZONTAL_SLIDER_MOVED:
913
940
# if ev.ui_element == self.slider_velocity:
914
941
# global self.options.velocity_curve
0 commit comments