-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.pde
58 lines (50 loc) · 1.43 KB
/
Utils.pde
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
long lastMeassureTime;
int messageCount;
int lastFullCount;
int audioOut, visualsOut;
void count() {
long now = millis();
if (now - lastMeassureTime > 1000) {
lastFullCount = messageCount;
//println( messageCount, audioOut, visualsOut);
messageCount = 0;
audioOut = 0;
visualsOut = 0;
lastMeassureTime = now;
}
messageCount++;
}
/*void countOut(int type) {
if (type == AUDIO)
audioOut++;
else
visualsOut++;
}*/
boolean readConfig() {
JSONObject main = loadJSONObject("config.json");
boolean useIt = main.getBoolean("useThis");
if (!useIt)
return false;
//
JSONArray sensorsJSON = main.getJSONArray("sensors");
flipInput = main.getBoolean("flip");
//
NUMBER_OF_INPUT_VALUES = sensorsJSON.size();
sensorNames = new String[NUMBER_OF_INPUT_VALUES];
sensors = new Sensor[NUMBER_OF_INPUT_VALUES];
for (int i = 0; i < NUMBER_OF_INPUT_VALUES; i++) {
sensorNames[i] = sensorsJSON.getString(i);
sensors[i] = new Sensor(sensorNames[i], i);
}
//
osc = new OscP5(this, main.getInt("listenPort"));
toAudio = new OscForward(main.getJSONObject("audio"));
toVisuals = new OscForward(main.getJSONObject("visuals"));
toRecorder = new OscForward(main.getJSONObject("record"));
return true;
}
void reloadNetworkDestinations() {
JSONObject main = loadJSONObject("config.json");
toAudio.resetNetowk(main.getJSONObject("audio"));
toVisuals.resetNetowk(main.getJSONObject("visuals"));
}