-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.js
81 lines (73 loc) · 2.47 KB
/
module.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
// Open Stage Control Custom Module
const cueAddresses = ['/cue/selected/displayName', '/cue/selected/notes'];
module.exports = {
init: () => {
const remote = settings.read('send')[0];
const host = remote.split(':')[0];
const port = remote.split(':')[1];
function refreshCues() {
for (const a of cueAddresses) {
send(host, port, a);
}
}
function refreshPatch() {
send(host, port, '/settings/light/patch');
}
function thump() {
send(host, port, '/thump');
}
setInterval(refreshCues, 0.5 * 1000);
setInterval(refreshPatch, 5 * 1000);
setInterval(thump, 30 * 1000);
},
oscInFilter: (data) => {
if (data.address.startsWith('/reply')) {
const regex = /^\/reply\/cue_id\/[A-Z0-9\-]+\/([a-zA-Z\/]+)$/;
if (regex.test(data.address)) {
data.address = data.address.replace(regex, '/cue/selected/$1');
} else {
data.address = data.address.replace(/^\/reply/, '');
}
const reply = JSON.parse(data.args[0].value);
if (reply.workspace_id) {
receive(
'127.0.0.1',
59000,
'/workspace_id',
reply.workspace_id
);
}
data.args = [
{
type: 's',
value: reply.data,
},
];
}
return data;
},
oscOutFilter: (data) => {
if (data.args.some((a) => a.value === 'rgb')) {
const index = data.args.findIndex((a) => a.value === 'rgb');
const [r, g, b] = data.args
.slice(index + 1, index + 4)
.map((a) => a.value);
data.args = data.args.slice(0, index);
data.args.push({
type: 's',
value: `rgb(${r},${g},${b})`,
});
} else if (data.args.some((a) => a.value === 'pantilt')) {
const index = data.args.findIndex((a) => a.value === 'pantilt');
const [pan, tilt] = data.args
.slice(index + 1, index + 3)
.map((a) => a.value);
data.args = data.args.slice(0, index);
data.args.push({
type: 's',
value: `pantilt(${pan},${tilt})`,
});
}
return data;
},
};