-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetCurrentReturns.js
72 lines (62 loc) · 1.63 KB
/
getCurrentReturns.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
/*
GetcCurrentReturns for OlimAutoSend device
Written by Domenico Graziano
november 2016
somewhere in Bristol
*/
//Useful log function found on http://compusition.com/ well done © Adam Murray 2007-2016
function log() {
for (var i = 0, len = arguments.length; i < len; i++) {
var message = arguments[i];
if (message && message.toString) {
var s = message.toString();
if (s.indexOf("[object ") >= 0) {
s = JSON.stringify(message);
}
post(s);
}
else if (message === null) {
post("<null>");
}
else {
post(message);
}
}
post("\n");
}
log("___________________________________________________");
log("Reload:", new Date);
function bang() {
getCurrentReturns();
}
outlets = 1;
Outlet = getCurrentReturns();
function getCurrentReturns() {
var thistrack = 'this_device canonical_parent mixer_device';
var mixerobject = new LiveAPI(thistrack);
var current_sends = countSends(mixerobject);
outlet(0, current_sends);
}
function isEven(n) {
return n % 2 == 0;
}
function countSends(mixerobject) {
alphabet = genCharArray('a', 'z');
current_sends = mixerobject.get('sends');
var counter = 0;
var sends = [];
for (i = 0; i < current_sends.length; i++) {
if (isEven(i)) {
sends.push(alphabet[counter]);
counter++;
}
}
return sends;
};
function genCharArray(charA, charZ) {
var a = [], i = charA.charCodeAt(0), j = charZ.charCodeAt(0);
for (; i <= j; ++i) {
a.push(String.fromCharCode(i));
}
return a;
}