-
Notifications
You must be signed in to change notification settings - Fork 1
/
MiniLab3Return.py
138 lines (98 loc) · 3.78 KB
/
MiniLab3Return.py
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
"""
[[
Surface: MiniLab3
Developer: Farès MEZDOUR
Version: 1.0.1
Copyright (c) 2022 Farès MEZDOUR
]]
"""
import ui
import time
import transport
import mixer
from MiniLab3Dispatch import send_to_device
# This class handles visual feedback functions.
WidMixer = 0
WidChannelRack = 1
WidPlaylist = 2
WidBrowser = 4
WidPlugin = 5
# MAPS
PAD_MAP = [
0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B]
COLOR_MAP = [
[0x00, 0x7F, 0x10],
[0x00, 0x7F, 0x19],
[0x00, 0x7F, 0x32],
[0x00, 0x7F, 0x4B],
[0x00, 0x7F, 0x64],
[0x00, 0x7F, 0x7F],
[0x00, 0x64, 0x7F],
[0x00, 0x4B, 0x7F],
[0x00, 0x32, 0x7F],
[0x00, 0x19, 0x7F],
[0x00, 0x00, 0x7F],
[0x19, 0x00, 0x7F],
[0x32, 0x00, 0x7F],
[0x4B, 0x00, 0x7F],
[0x64, 0x00, 0x7F],
[0x7F, 0x00, 0x7F],
[0x7F, 0x00, 0x64],
[0x7F, 0x00, 0x4B],
[0x7F, 0x00, 0x32],
[0x7F, 0x00, 0x19],
[0x7F, 0x00, 0x00],
[0x7F, 0x19, 0x00],
[0x7F, 0x32, 0x00],
[0x7F, 0x4B, 0x00],
]
class MiniLabLightReturn:
def init(self) :
send_to_device(bytes([0x04, 0x02, 0x16, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x7F, 0x00, 0x00]))
time.sleep(0.2)
send_to_device(bytes([0x04, 0x02, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
time.sleep(0.2)
send_to_device(bytes([0x04, 0x02, 0x16, 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14]))
def MetronomeReturn(self) :
if ui.isMetronomeEnabled() :
send_to_device(bytes([0x02, 0x02, 0x16, 0x54, 0x7F, 0x7F, 0x00]))
else :
send_to_device(bytes([0x02, 0x02, 0x16, 0x54, 0x14, 0x14, 0x00]))
def LoopReturn(self) :
if ui.isLoopRecEnabled() :
send_to_device(bytes([0x02, 0x02, 0x16, 0x57, 0x7F, 0x32, 0x00]))
else :
send_to_device(bytes([0x02, 0x02, 0x16, 0x57, 0x14, 0x05, 0x00]))
def RecordReturn(self) :
if transport.isRecording() :
send_to_device(bytes([0x02, 0x02, 0x16, 0x5A, 0x7F, 0x00, 0x00]))
else :
send_to_device(bytes([0x02, 0x02, 0x16, 0x5A, 0x14, 0x00, 0x00]))
def PlayReturn(self) :
if mixer.getSongTickPos() != 0 :
send_to_device(bytes([0x02, 0x02, 0x16, 0x59, 0x00, 0x7F, 0x00]))
else :
send_to_device(bytes([0x02, 0x02, 0x16, 0x59, 0x00, 0x14, 0x00]))
def ProcessPlayBlink(self, value):
COLOR_PLAY_ON = bytes([0x02, 0x02, 0x16, 0x59, 0x00, 0x7F, 0x00])
COLOR_PLAY_OFF = bytes([0x02, 0x02, 0x16, 0x59, 0x00, 0x14, 0x00])
if value == 0 :
send_to_device(COLOR_PLAY_OFF)
else :
send_to_device(COLOR_PLAY_ON)
def ProcessRecordBlink(self, value) :
if transport.isRecording() :
COLOR_RECORDING_ON = bytes([0x02, 0x02, 0x16, 0x5A, 0x7F, 0x00, 0x00])
COLOR_RECORDING_OFF = bytes([0x02, 0x02, 0x16, 0x5A, 0x14, 0x00, 0x00])
if value == 0 :
send_to_device(COLOR_RECORDING_OFF)
else :
send_to_device(COLOR_RECORDING_ON)
def LEDTest(self) :
send_to_device(bytes([0x02, 0x02, 0x16, 0x04, 0x00, 0x00, 0x7f]))
send_to_device(bytes([0x02, 0x02, 0x16, 0x05, 0x00, 0x00, 0x00]))
time.sleep(0.1)
send_to_device(bytes([0x02, 0x02, 0x16, 0x04, 0x00, 0x00, 0x00]))
send_to_device(bytes([0x02, 0x02, 0x16, 0x05, 0x00, 0x00, 0x7f]))
time.sleep(0.1)