-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaint.py
More file actions
112 lines (99 loc) · 2.75 KB
/
Copy pathpaint.py
File metadata and controls
112 lines (99 loc) · 2.75 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Credits: WolFuRi (https://github.com/wolfur1)
from pygame import midi
from time import sleep
import mido
from ports import *
midi.init()
dev = midi.Input(MIDI_OUTPUT)
output = mido.open_output(MIDI_OUTPUT_MIDO)
keys = {}
mapping = [
91, 92, 93, 94, 95, 96, 97, 98, 99,
81, 82, 83, 84, 85, 86, 87, 88, 89,
71, 72, 73, 74, 75, 76, 77, 78, 79,
61, 62, 63, 64, 65, 66, 67, 68, 69,
51, 52, 53, 54, 55, 56, 57, 58, 59,
41, 42, 43, 44, 45, 46, 47, 48, 49,
31, 32, 33, 34, 35, 36, 37, 38, 39,
21, 22, 23, 24, 25, 26, 27, 28, 29,
11, 12, 13, 14, 15, 16, 17, 18, 19,
]
color_palet = {
89: 3,
79: 5,
69: 9,
59: 13,
49: 21,
39: 37,
39: 45,
29: 53,
19: 0
}
special_keys = {
98: True,
97: False
}
right_side = {
89: 0,
79: 0,
69: 0,
59: 0,
49: 0,
39: 0,
39: 0,
29: 0,
19: 0
}
def DrawColorPalet(mode: int = 0):
if special_keys[98]:
for k in color_palet:
output.send(mido.Message('note_on', note=k, velocity=color_palet[k]))
output.send(mido.Message('note_on', note=98, velocity=21))
else:
for k in right_side:
output.send(mido.Message('note_on', note=k, velocity=right_side[k]))
output.send(mido.Message('note_on', note=98, velocity=5))
def DrawMenu():
for k in special_keys:
if k==98:
if special_keys[k]: output.send(mido.Message('note_on', note=k, velocity=21))
else: output.send(mido.Message('note_on', note=k, velocity=5))
if k==97:
output.send(mido.Message('note_on', note=k, velocity=53))
def ClearALL():
if special_keys[97]:
for k in right_side:
right_side[k] = 0
for k in mapping:
output.send(mido.Message('note_on', note=k, velocity=0))
output.send(mido.Message('note_on', note=99, velocity=color))
special_keys[97] = False
Update()
def Update():
DrawMenu()
DrawColorPalet()
ClearALL()
output.send(mido.Message('note_on', note=99, velocity=color))
color = 3
frame = 0
Update()
while True:
while dev.poll():
x = dev.read(1)
note = x[0][0][1]
if x[0][0][2] == 127:
print(x)
if note in special_keys:
special_keys[note] = not special_keys[note]
elif note in color_palet and special_keys[98]:
if not special_keys[98]: continue
color = color_palet[note]
else:
if not note in keys:
keys[note] = 0
output.send(mido.Message('note_on', note=note, velocity=color))
keys[note] = 1
if note in right_side:
right_side[note] = color
Update()
sleep(0.05)