-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusage.py
More file actions
58 lines (50 loc) · 1.59 KB
/
Copy pathusage.py
File metadata and controls
58 lines (50 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import csv
import itertools
import time
import sys
from launchpad import LaunchPadProMk2
def callback(msg):
if msg.type == 'sysex':
print('sysex:', msg.data)
elif msg.type == 'note_on':
print(f"note on: {msg.note}, velocity={msg.velocity}")
elif msg.type == 'cc':
print(f"cc on: {msg.note}, velocity={msg.velocity}")
# NOTE: LAUNCHPAD doesn't use 'note_off'
# elif msg.type == 'note_off':
# print(msg)
if __name__ == '__main__':
device = LaunchPadProMk2(mode="STANDALONE")
device.open(callback=callback)
# device.change_layout("note")
# device.change_layout("drum")
# device.change_layout("fader")
device.change_layout("programmer")
# Operate LED with sysex
with open('led.csv') as f:
led_csv = csv.reader(f)
leds = [list(map(int, r)) for r in led_csv]
leds = list(itertools.chain.from_iterable(leds[1:]))
device.set_lit(colores=leds)
time.sleep(0.3)
device.column_lit(0, colores=[12, 13, 14, 15, 16, 17, 18, 19, 20, 21])
time.sleep(0.3)
device.row_lit(0, colores=[12, 13, 14, 15, 16, 17, 18, 19, 20, 21])
time.sleep(0.3)
device.all_lit(color=6)
time.sleep(0.3)
# Operate LED with note
device.all_on()
time.sleep(0.3)
device.all_off()
# Wait for exit
exit = lambda: [device.close(), sys.exit(0)]
while True:
try:
keys = input("Press Ctrl+C to exit or enter quit.")
except KeyboardInterrupt:
exit()
if keys == 'quit' or keys == "q":
exit()