Skip to content

Commit 44cadce

Browse files
committed
launchpad aftertouch
1 parent d79f76d commit 44cadce

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

app.py

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ def note_on(self, data, timestamp, width=None, curve=True, no_overlap=None):
345345
# print(data)
346346
ch = d0 & 0x0F
347347
msg = (data[0] & 0xF0) >> 4
348+
aftertouch = (msg == 10)
348349
if self.options.one_channel:
349350
data[0] = d0 & 0xF0 # send all to channel 0 if enabled
350351
row = None
@@ -373,14 +374,16 @@ def note_on(self, data, timestamp, width=None, curve=True, no_overlap=None):
373374
midinote = data[1] - 24 + self.transpose * 2
374375
if self.is_split():
375376
split_chan = self.channel_from_split(row, col)
376-
self.mark(midinote, 1, only_row=row)
377+
if not aftertouch:
378+
self.mark(midinote, 1, only_row=row)
377379
data[1] += self.out_octave * 12 + self.transpose * 2
378380
if self.flipped:
379381
data[1] += 7
380382

381-
# apply velocity curve
383+
# velocity (or pressure if aftertouch)
382384
vel = data[2] / 127
383-
if curve:
385+
if curve and not aftertouch:
386+
# apply curve
384387
if self.has_velocity_settings():
385388
vel = self.velocity_curve(data[2] / 127)
386389
data[2] = clamp(
@@ -550,10 +553,10 @@ def cb_launchpad_in(self, event, timestamp):
550553
x = event[1] % 10 - 1
551554
state = self.launchpad_state[y][x]
552555
self.launchpad_state[y][x] = event[2]
556+
note = y * 8 + x
553557
if state is None: # just pressed
554-
note = y * 8 + x
555558
self.note_on([144, note, event[2]], timestamp, width=8, no_overlap=True, curve=False)
556-
# TODO: write pressure
559+
self.note_on([160, note, event[2]], timestamp, width=8, no_overlap=True, curve=False)
557560
elif event[0] == 176:
558561
if event == [176, 93, 127, 0]:
559562
self.transpose_board(-1)
@@ -592,26 +595,28 @@ def cb_launchpad_in(self, event, timestamp):
592595
# with open('settings_temp.ini', 'w') as configfile:
593596
# self.cfg.write(configfile)
594597

595-
def init_launchpad(self):
596-
pattern = [
597-
'ggggbb',
598-
'cggbbb',
599-
]
600-
601-
for y in range(1, 9):
602-
for x in range(0, 8):
603-
yy = y - 2
604-
xx = x
605-
yy -= 3
606-
xx -= (8-yy-1)//2
607-
col = pattern[yy%2][xx%6]
608-
if col == 'c': #cyan
609-
col = [0, 63, 63]
610-
elif col == 'g': #green
611-
col = [0, 63, 0]
612-
elif col == 'b': #black
613-
col = [0, 0, 0]
614-
self.launchpad.LedCtrlXY(x, y, col[0], col[1], col[2])
598+
# def init_launchpad(self):
599+
# pattern = [
600+
# 'ggggbb',
601+
# 'cggbbb',
602+
# ]
603+
604+
# self.launchpad.LedCtrlXY(x, y+1, lp_col[0], lp_col[1], lp_col[2])
605+
606+
# for y in range(1, 9):
607+
# for x in range(0, 8):
608+
# yy = y - 2
609+
# xx = x
610+
# yy -= 3
611+
# xx -= (8-yy-1)//2
612+
# col = pattern[yy%2][xx%6]
613+
# if col == 'c': #cyan
614+
# col = [0, 63, 63]
615+
# elif col == 'g': #green
616+
# col = [0, 63, 0]
617+
# elif col == 'b': #black
618+
# col = [0, 0, 0]
619+
# self.launchpad.LedCtrlXY(x, y, col[0], col[1], col[2])
615620

616621
def __init__(self):
617622
self.cfg = ConfigParser(allow_no_value=True)
@@ -932,7 +937,7 @@ def __init__(self):
932937
mode = "lpx"
933938
if mode is not None:
934939
self.launchpad = lp
935-
self.init_launchpad()
940+
# self.init_launchpad()
936941

937942
self.done = False
938943

0 commit comments

Comments
 (0)