-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathAPC light-pad utilities
67 lines (61 loc) · 1.57 KB
/
APC light-pad utilities
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
59
60
61
62
63
64
65
66
67
#Utilities for light-up pads on APCs
#https://youtu.be/3vBmxArxQVE
num_keys = 40 #Adapt to your device
#Clear the pads
live_loop :apc_clear do
key, val = sync ''
if key == 81
for i in (range 0,num_keys)
midi_note_on i,0,channel: 1
end
end
puts "cleared"
end
#Display
frame = [1,0,3,0,1,0,3,0,
0,1,3,1,0,1,3,1,
3,3,1,3,3,3,1,3,
0,1,3,1,0,1,3,1,
1,0,3,0,1,0,3,0]
#Set to 1 for green, 3 for red and 5 for yellow
define :apc_display do |frame|
for i in (range 0,num_keys)
midi_note_on i,frame[i],channel: 1
end
puts "displayed frame"
end
#Cycle frames
frames = [[1,0,0,0,0,0,0,0,
1,0,0,1,0,0,0,0,
1,0,0,1,0,0,0,0,
1,0,0,1,0,0,0,0,
1,1,1,1,1,1,1,1],
[0,0,1,1,1,1,0,0,
0,1,0,0,0,0,1,0,
1,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1]]
#Each of these blocks is a frame
comment do
live_loop :apc_frames do
apc_display frames.ring.tick
sleep 1 #Adapt for FPS
end
end
#Switch value on button press and switch it on/off
button = 64 #Whatever button you want to use
live_loop :listen_b0 do
key, vel = sync "" #After pressing the button, the name should appear in the lower right window
#'the key, vel =' is nessessary because sync returns two values
if key == button #if the button pressed is the one you wanted
var = (ring 0,1).tick
midi_note_on
end
end
#Randomly switch the pads
comment do
live_loop :rand_pads do
midi_note_on (range 0,num_keys).choose,(ring 0,1,3,5).choose, channel: 1
sleep 0.1
end
end