@@ -116,17 +116,17 @@ def send_cc(self, channel, cc, val):
116116 self .linn_out .send_cc (channel , cc , val )
117117 # self.linn_out.send_messages(0xb0, [(channel, cc, val)])
118118
119- def set_light (self , x , y , col , index = None ): # col is [1,11], 0 resets
119+ def set_light (self , x , y , col , index = None , mark = False ): # col is [1,11], 0 resets
120120 """Set light to color `col` at x, y if in range and connected"""
121- if y < 0 or y > self .board_h :
121+ if y < 0 or y >= self .board_h :
122122 return
123- if x < 0 or x > self .board_w :
123+ if x < 0 or x >= self .board_w :
124124 return
125125
126126 if not index :
127127 index = self .get_note_index (x , y )
128128
129- self .red_lights [y ][x ] = ( col == 1 )
129+ self .mark_lights [y ][x ] = mark
130130 if self .linn_out :
131131 self .send_cc (0 , 20 , x + 1 )
132132 self .send_cc (0 , 21 , self .board_h - y - 1 )
@@ -169,7 +169,7 @@ def reset_light(self, x, y, reset_red=True):
169169 light_col = 7
170170
171171 self .set_light (x , y , light_col , note )
172- self .red_lights [y ][x ] = False
172+ self .mark_lights [y ][x ] = False
173173
174174 def reset_launchpad_light (self , x , y ):
175175 """Reset the launchpad light at x, y"""
@@ -184,11 +184,11 @@ def reset_launchpad_light(self, x, y):
184184 # light_col = self.options.lights[note]
185185 self .set_launchpad_light (x , y , note )
186186
187- def set_red_light (self , x , y , state = True ):
187+ def set_mark_light (self , x , y , state = True ):
188188 """Set launchpad light to touched color"""
189- self .red_lights [y ][x ] = state
189+ self .mark_lights [y ][x ] = state
190190 if self .launchpad :
191- lp_col = ivec3 ( 63 , 0 , 0 )
191+ lp_col = self . options . mark_color
192192 if state :
193193 self .launchpad .LedCtrlXY (x , y , lp_col [0 ], lp_col [1 ], lp_col [2 ])
194194
@@ -206,8 +206,8 @@ def setup_lights(self):
206206 """Set all lights"""
207207 for y in range (self .board_h ):
208208 for x in range (self .board_w ):
209- if self .red_lights [y ][x ]:
210- self .set_red_light (x , y , True )
209+ if self .mark_lights [y ][x ]:
210+ self .set_mark_light (x , y , True )
211211 else :
212212 self .reset_light (x , y )
213213
@@ -256,30 +256,33 @@ def get_color(self, x, y):
256256 # return NOTE_COLORS[get_note_index(x, y)]
257257 note = self .get_note_index (x , y )
258258 # note = (note - self.tonic) % 12
259- if self .is_split ():
260- split_chan = self .channel_from_split (x , self .board_h - y - 1 )
261- if split_chan :
262- light_col = self .options .split_lights [note ]
263- try :
264- light_col = light_col if self .scale_notes [note ]!= '.' else 7
265- except IndexError :
266- light_col = 7
267- else :
268- light_col = self .options .lights [note ]
269- try :
270- light_col = light_col if self .scale_notes [note ]!= '.' else 7
271- except IndexError :
272- light_col = 7
259+ # if self.is_split():
260+ # split_chan = self.channel_from_split(x, self.board_h - y - 1)
261+ # if split_chan:
262+ # light_col = self.options.split_lights[note]
263+ # try:
264+ # light_col = light_col if self.scale_notes[note]!='.' else 7
265+ # except IndexError:
266+ # light_col = 7
267+ # else:
268+ # light_col = self.options.lights[note]
269+ # try:
270+ # light_col = light_col if self.scale_notes[note]!='.' else 7
271+ # except IndexError:
272+ # light_col = 7
273273
274- else :
275- light_col = self .options .lights [note ]
276- try :
277- light_col = light_col if self .scale_notes [note ]!= '.' else 7
278- except IndexError :
279- light_col = 7
274+ # else:
275+ # light_col = self.options.lights[note]
276+ # try:
277+ # light_col = light_col if self.scale_notes[note]!='.' else 7
278+ # except IndexError:
279+ # light_col = 7
280280
281281 if self .scale_notes [note ] != '.' :
282- return self .options .colors [note ]
282+ if self .channel_from_split (x , self .board_h - y - 1 ):
283+ return self .options .split_colors [note ]
284+ else :
285+ return self .options .colors [note ]
283286 else :
284287 return None
285288
@@ -1083,6 +1086,10 @@ def __init__(self):
10831086 self .options .colors = list (self .options .colors .split ("," ))
10841087 self .options .colors = list (map (lambda x : glm .ivec3 (get_color (x )), self .options .colors ))
10851088
1089+ self .options .split_colors = get_option (opts , "colors" , DEFAULT_OPTIONS .split_colors )
1090+ self .options .split_colors = list (self .options .split_colors .split ("," ))
1091+ self .options .split_colors = list (map (lambda x : glm .ivec3 (get_color (x )), self .options .split_colors ))
1092+
10861093 # LIGHT = ivec3(127)
10871094 self .options .lights = get_option (opts , "lights" , DEFAULT_OPTIONS .lights )
10881095 if self .options .lights :
@@ -1102,6 +1109,8 @@ def __init__(self):
11021109
11031110 if len (self .options .colors ) != 12 :
11041111 error ("Invalid color configuration. Make sure you have 12 colors under the colors option or remove it." )
1112+ if len (self .options .split_colors ) != 12 :
1113+ error ("Invalid split color configuration. Make sure you have 12 colors under the split_colors option or remove it." )
11051114 if len (self .options .lights ) != 12 :
11061115 error ("Invalid light color configuration. Make sure you have 12 light colors under the lights option or remove it." )
11071116 if len (self .options .split_lights ) != 12 :
@@ -1134,6 +1143,14 @@ def __init__(self):
11341143 if self .options .velocity_curve < EPSILON : # if its near zero, set default
11351144 self .options .velocity_curve = 1.0 # default
11361145
1146+ self .options .mark_light = get_option (
1147+ opts , "mark_light" , DEFAULT_OPTIONS .mark_light
1148+ )
1149+ self .options .mark_color = get_option (
1150+ opts , "mark_color" , DEFAULT_OPTIONS .mark_color
1151+ )
1152+ self .options .mark_color = glm .ivec3 (get_color (self .options .mark_color ))
1153+
11371154 self .options .min_velocity = get_option (
11381155 opts , "min_velocity" , DEFAULT_OPTIONS .min_velocity
11391156 )
@@ -1534,7 +1551,7 @@ def __init__(self):
15341551 w = self .max_width
15351552 h = self .board_h
15361553 self .board = [[0 for x in range (w )] for y in range (h )]
1537- self .red_lights = [[False for x in range (w )] for y in range (h )]
1554+ self .mark_lights = [[False for x in range (w )] for y in range (h )]
15381555 self .launchpad_state = [[None for x in range (8 )] for y in range (8 )]
15391556
15401557 self .font = pygame .font .Font (None , FONT_SZ )
@@ -1719,7 +1736,7 @@ def mark_xy(self, x, y, state, use_lights=False):
17191736 pass
17201737 if use_lights :
17211738 if state :
1722- self .set_light (x , y , 1 )
1739+ self .set_light (x , y , self . options . mark_light , mark = True )
17231740 else :
17241741 self .reset_light (x , y )
17251742 self .dirty = True
@@ -1748,7 +1765,7 @@ def mark(self, midinote, state, use_lights=False, only_row=None):
17481765 self .board [y + self .flipped ][x ] = state
17491766 if use_lights :
17501767 if state :
1751- self .set_light (x , y , 1 )
1768+ self .set_light (x , y , self . options . mark_light , mark = True )
17521769 else :
17531770 self .reset_light (x , y )
17541771 y += 1
0 commit comments