forked from LykaiosNZ/companion-module-cockos-reaper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
feedback.js
359 lines (331 loc) · 9.02 KB
/
feedback.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
module.exports = {
/**
* INTERNAL: Get the available feedbacks.
*
* @returns {Object[]} the available feedbacks
* @access protected
* @since 1.0.0
*/
getFeedbacks() {
var self = this
var feedbacks = {}
feedbacks['playStatus'] = {
type: 'boolean',
label: 'Change style based on Play/Pause status',
description: 'Change style based on Play/Pause status',
style: {
color: self.rgb(255, 255, 255),
bgcolor: self.rgb(0, 183, 0)
},
options: [
{
type: 'dropdown',
label: 'Status',
id: 'playPause',
default: 'Playing',
choices: [
{id: 'Playing', label: 'Playing'},
{id: 'Paused', label: 'Paused'}
]
}
],
callback: (feedback, bank) => {
if (this.playStatus === feedback.options.playPause) {
return true;
}
return false;
}
}
feedbacks['stopStatus'] = {
type: 'boolean',
label: 'Change style based on Stop status',
description: 'Change style based on Stop status',
style: {
color: self.rgb(255, 255, 255),
bgcolor: self.rgb(76, 76, 76)
},
options: [
{
type: 'dropdown',
label: 'Status',
id: 'stopPlay',
default: 'Stopped',
choices: [
{id: 'Stopped', label: 'Stopped'},
{id: 'Playing', label: 'Playing'}
]
}
], callback: (feedback, bank) => {
if (this.stopStatus === feedback.options.stopPlay) {
return true;
}
return false;
}
}
feedbacks['recordStatus'] = {
type: 'boolean',
label: 'Change style based on Record status',
description: 'Change style based on Record status',
style: {
color: self.rgb(255, 255, 255),
bgcolor: self.rgb(183, 0, 0)
},
options: [
{
type: 'dropdown',
label: 'Status',
id: 'recordOrNot',
default: 'Recording',
choices: [
{id: 'Recording', label: 'Recording'},
{id: 'Not Recording', label: 'Not Recording'}
]
}
], callback: (feedback, bank) => {
if (this.recordStatus === feedback.options.recordOrNot) {
return true;
}
return false;
}
}
feedbacks['rewindStatus'] = {
type: 'boolean',
label: 'Change style based on Rewind status',
description: 'Change style based on Rewind status',
style: {
color: self.rgb(255, 255, 255),
bgcolor: self.rgb(249, 199, 0)
},
options: [
{
type: 'dropdown',
label: 'Status',
id: 'rewindOrNot',
default: 'Rewinding',
choices: [
{id: 'Rewinding', label: 'Rewinding'},
{id: 'Not Rewinding', label: 'Not Rewinding'}
]
}
], callback: (feedback, bank) => {
if (this.rewindStatus === feedback.options.rewindOrNot) {
return true;
}
return false;
}
}
feedbacks['forwardStatus'] = {
type: 'boolean',
label: 'Change style based on Fast Forward status',
description: 'Change style based on Fast Forward status',
style: {
color: self.rgb(255, 255, 255),
bgcolor: self.rgb(249, 199, 0)
},
options: [
{
type: 'dropdown',
label: 'Status',
id: 'forwardOrNot',
default: 'Forwarding',
choices: [
{id: 'Forwarding', label: 'Forwarding'},
{id: 'Not Forwarding', label: 'Not Forwarding'}
]
}
], callback: (feedback, bank) => {
if (this.forwardStatus === feedback.options.forwardOrNot) {
return true;
}
return false;
}
}
feedbacks['repeatStatus'] = {
type: 'boolean',
label: 'Change style based on Repeat status',
description: 'Change style based on Repeat status',
style: {
color: self.rgb(255, 255, 255),
bgcolor: self.rgb(153, 0, 153)
},
options: [
{
type: 'dropdown',
label: 'Status',
id: 'repeatOrNot',
default: 'Active',
choices: [
{id: 'Active', label: 'Active'},
{id: 'Inactive', label: 'Inactive'}
]
}
], callback: (feedback, bank) => {
if (this.repeatStatus === feedback.options.repeatOrNot) {
return true;
}
return false;
}
}
feedbacks['clickStatus'] = {
type: 'boolean',
label: 'Change style based on Click status',
description: 'Change style based on Click status',
style: {
color: self.rgb(255, 255, 255),
bgcolor: self.rgb(11, 138, 179)
},
options: [
{
type: 'dropdown',
label: 'Status',
id: 'clickOrNot',
default: 'Active',
choices: [
{id: 'Active', label: 'Active'},
{id: 'Inactive', label: 'Inactive'}
]
}
], callback: (feedback, bank) => {
if (this.clickStatus === feedback.options.clickOrNot) {
return true;
}
return false;
}
}
feedbacks['customMessage'] = {
type: 'boolean',
label: 'Change style based on a custom OSC message',
description: 'Change style based on a custom OSC message',
style: {
color: self.rgb(255, 255, 255),
bgcolor: self.rgb(0, 255, 0)
},
options: [
{
type: 'textinput',
label: 'Message',
id: 'msg',
default: '/repeat'
},
{
type: 'dropdown',
label: 'Message Type',
id: 'type',
default: 'f',
choices: [
{id: 'f', label: 'Number'},
{id: 's', label: 'String'}
]
},
{
type: 'textinput',
label: 'Value',
id: 'value',
default: '1'
}
], callback: (feedback, bank) => {
var self = this;
var foundFeedback;
self.customMessages.forEach(function (customMessage, index) {
if (self.customMessageStatus[customMessage.id].toString() === feedback.options.value) {
if (customMessage.address === feedback.options.msg &&
customMessage.args.type === feedback.options.type &&
customMessage.args.value.toString() === feedback.options.value
) {
foundFeedback = feedback
}
}
});
if (foundFeedback !== undefined) {
return true;
}
return false;
}
}
// Track Feedbacks
feedbacks['track_mute'] = self.createBooleanTrackFeedback('mute', 'Change style when a track is muted', 'Change style when a track is muted');
feedbacks['track_solo'] = self.createBooleanTrackFeedback('solo', 'Change style when a track is soloed', 'Change style when a track is soloed');
feedbacks['track_recarm'] = self.createBooleanTrackFeedback('recarm', 'Change style when a track is armed for recording', 'Change style when a track is armed for recording');
feedbacks['track_select'] = self.createBooleanTrackFeedback('select', 'Change style when a track is selected', 'Change style when a track is selected');
feedbacks['track_monitor'] = self.createBooleanTrackFeedback('monitor', 'Change style when monitoring is enabled for a track', 'Change style when monitoring is enabled for a track');
// Track FX Feedbacks
feedbacks['track_fx_bypass'] = self.createBooleanTrackFxFeedback('bypass', 'Change style when an FX is active', 'Change style when an FX is active');
feedbacks['track_fx_openui'] = self.createBooleanTrackFxFeedback('openui', 'Change style when an FX UI window is open', 'Change style when an FX UI window is open');
return feedbacks;
},
// Condenses feedback options to an object containing id and default value alone for all feedback options
getFeedbackDefaultOptions(feedbackType) {
var self = this
return self.getFeedbacks()[feedbackType].options.map(e => [e.id, e.default]).reduce(function (p, c) {
p[c[0]] = c[1];
return p;
}, {})
},
getFeedbackDefaultStyle(feedbackType) {
var self = this
return self.getFeedbacks()[feedbackType].style;
},
createBooleanTrackFeedback(propertyName, label, description)
{
var self = this;
return {
type: 'boolean',
label: label,
description: description,
style: {
color: self.rgb(255, 255, 255),
bgcolor: self.rgb(0, 255, 0)
},
options: [
{
type: 'number',
label: 'Track Number',
id: 'trackNumber',
default: 1
}
], callback: (feedback, bank) => {
var self = this;
var track = self.getTrack(feedback.options.trackNumber);
if (track !== undefined && track[propertyName] === true)
{
return true;
}
return false;
}
}
},
createBooleanTrackFxFeedback(propertyName, label, description) {
var self = this;
return {
type: 'boolean',
label: label,
description: description,
style: {
color: self.rgb(255, 255, 255),
bgcolor: self.rgb(0, 255, 0)
},
options: [
{
type: 'number',
label: 'Track Number',
id: 'trackNumber',
default: 1
},
{
type: 'number',
label: 'FX Number',
id: 'fxNumber',
default: 1
}
], callback: (feedback, bank) => {
var self = this;
var fx = self.getTrackFx(feedback.options.trackNumber, feedback.options.fxNumber);
if (fx !== undefined && fx[propertyName] === true)
{
return true;
}
return false;
}
}
}
}