-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyLabEssentialsProtocol.js
145 lines (135 loc) · 4.05 KB
/
KeyLabEssentialsProtocol.js
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
class TextLine {
constructor(lineNr, length) {
this.lineNr = lineNr;
this.length = length;
}
}
class ContextLED {
constructor(buttonNr) {
this.buttonNr = buttonNr;
}
}
class Knob {
constructor(knobNr) {
this.knobNr = knobNr;
this.sysExKnobIndex = knobNr + 2;
this.midiControl = 0x5F + knobNr;
}
}
class KeyLabEssentialsProtocol {
static buildMakeConnectionSysex(buffer) {
buffer.begin(KeyLabEssentialsProtocol.sysexHeader);
buffer.push(0x02);
buffer.push(0x0F);
buffer.push(0x40);
buffer.push(0x5A);
buffer.push(0x01);
buffer.end();
return buffer;
}
static buildEndConnectionSysex(buffer) {
buffer.begin(KeyLabEssentialsProtocol.sysexHeader);
buffer.push(0x02);
buffer.push(0x0F);
buffer.push(0x40);
buffer.push(0x5A);
buffer.push(0x00);
buffer.end();
return buffer;
}
static buildTextSysex(buffer, line, text) {
buffer.begin(KeyLabEssentialsProtocol.sysexHeader);
buffer.push(0x04);
buffer.push(0x01);
buffer.push(0x60);
buffer.push(0x12);
buffer.push(line);
buffer.appendAscii(text);
buffer.push(0x00);
buffer.end();
return buffer;
}
static buildContextButtonsSysex(buffer) {
buffer.begin(KeyLabEssentialsProtocol.sysexHeader);
buffer.push(0x04);
buffer.push(0x01);
buffer.push(0x60);
buffer.push(0x03);
buffer.push(0x22);
buffer.push(0x42);
buffer.push(0x00);
buffer.push(0x32);
buffer.push(0x23);
buffer.push(0x00);
buffer.push(0x42);
buffer.push(0x24);
buffer.push(0x00);
buffer.end();
return buffer;
}
static buildRGBButtonSysex(buffer, buttonId, r, g, b) {
buffer.begin(KeyLabEssentialsProtocol.sysexHeader);
buffer.push(0x04);
buffer.push(0x01);
buffer.push(0x16);
buffer.push(buttonId);
buffer.push(r);
buffer.push(g);
buffer.push(b);
buffer.end();
return buffer;
}
static buildSetKnobValueSysex(buffer, sysExKnobIndex, value) {
buffer.begin(KeyLabEssentialsProtocol.sysexHeader);
buffer.push(0x02);
buffer.push(0x0F);
buffer.push(0x40);
buffer.push(sysExKnobIndex);
buffer.push(value);
buffer.end();
return buffer;
}
static buildDisplayKnobValueSysex(buffer, name, value) {
buffer.begin(KeyLabEssentialsProtocol.sysexHeader);
// 00 02 (line_2) 00 03 (hw_value) 00 (transient)
buffer.push(0x04);
buffer.push(0x01);
buffer.push(0x60);
buffer.push(0x14);
buffer.push(0x01);
buffer.appendAscii("Knob: " + value.toString());
buffer.push(0x00);
buffer.push(0x02);
buffer.appendAscii(name);
buffer.push(0x00);
buffer.push(0x03);
buffer.push(value);
buffer.push(0x01);
buffer.end();
return buffer;
}
}
KeyLabEssentialsProtocol.line1Text = new TextLine(1, 18);
KeyLabEssentialsProtocol.line2Text = new TextLine(2, 18);
KeyLabEssentialsProtocol.loopLED = new ContextLED(0x10);
KeyLabEssentialsProtocol.metronomeLED = new ContextLED(0x13);
KeyLabEssentialsProtocol.contextLED0 = new ContextLED(0x18);
KeyLabEssentialsProtocol.contextLED1 = new ContextLED(0x19);
KeyLabEssentialsProtocol.contextLED2 = new ContextLED(0x1A);
KeyLabEssentialsProtocol.contextLED3 = new ContextLED(0x1B);
KeyLabEssentialsProtocol.knob1 = new Knob(1);
KeyLabEssentialsProtocol.knob2 = new Knob(2);
KeyLabEssentialsProtocol.knob3 = new Knob(3);
KeyLabEssentialsProtocol.knob4 = new Knob(4);
KeyLabEssentialsProtocol.knob5 = new Knob(5);
KeyLabEssentialsProtocol.knob6 = new Knob(6);
KeyLabEssentialsProtocol.knob7 = new Knob(7);
KeyLabEssentialsProtocol.knob8 = new Knob(8);
KeyLabEssentialsProtocol.knob9 = new Knob(9);
KeyLabEssentialsProtocol.sysexHeader = [
0x00,
0x20,
0x6B,
0x7F,
0x42
];