-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLOMjsObj.js
123 lines (79 loc) · 2.39 KB
/
LOMjsObj.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
/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */
// file for the JS max object
outlets = 3;
// call and set
function call(path, order){
outlet(0, [path, order]);
LiveAPI(path).call(order);
// nothing to return- unidirectional
}
function set(path, prop, value){
outlet(0, path, prop, value);
LiveAPI(path).set(prop, value);
// nothing to return - unidirectional
}
// get
function get(path, prop){
outlet(0, path, prop);
outlet( 1, 'got', path, prop, LiveAPI(path).get(prop) );
}
// count
function count(path, prop){
outlet(0, path, prop);
outlet(1, 'got', path, prop, LiveAPI(path).getcount(prop));
}
// observer
observeCB = function(valChange){
post('observer CB: ', this.path, valChange);
outlet(1, 'observed', this.path, valChange);
// the cb argument is the property
// and the changed value
};
var obs1 = new LiveAPI(observeCB);
var obs2 = new LiveAPI(observeCB);
var obs3 = new LiveAPI(observeCB);
var obs4 = new LiveAPI(observeCB);
var obs5 = new LiveAPI(observeCB);
var obs6 = new LiveAPI(observeCB);
var obs7 = new LiveAPI(observeCB);
var obs8 = new LiveAPI(observeCB);
var obs9 = new LiveAPI(observeCB);
var obs10 = new LiveAPI(observeCB);
var obs11 = new LiveAPI(observeCB);
var obs12 = new LiveAPI(observeCB);
var obs13 = new LiveAPI(observeCB);
var obs14 = new LiveAPI(observeCB);
var obs15 = new LiveAPI(observeCB);
var obs16 = new LiveAPI(observeCB);
var obs17 = new LiveAPI(observeCB);
var obs18 = new LiveAPI(observeCB);
var obs19 = new LiveAPI(observeCB);
var obs20 = new LiveAPI(observeCB);
var obsArr = [obs1, obs2, obs3, obs4, obs5, obs6, obs7, obs8, obs9, obs10,
obs11, obs12, obs13, obs14, obs15, obs16, obs17, obs18, obs19, obs20];
function obsSet(observer, INpath, INproperty){
post(observer, INpath, INproperty);
if (observer === 'reset'){
obsReset();
}
else {
obsArr[observer].path = INpath; // "live_set master_track mixer_device volume";
obsArr[observer].property = INproperty; // "value";
obsArr[observer].mode = 1; // prevents assignment from changing if the order of the tracks changes
}
}
/*
reset the observers to a value that will never
change- otherwise the callback in the LOM.js lib
will throw errors if Live is running while the server
restarts
*/
function obsReset(){
for (var i = 0; i < obsArr.length; i++){
obsSet(i, 'live_set', 'root_note');
}
}
function display(message){
outlet(2, message);
}