-
Notifications
You must be signed in to change notification settings - Fork 1
/
tinydata.pde
68 lines (54 loc) · 1.2 KB
/
tinydata.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
59
60
61
62
63
64
65
66
67
import ddf.minim.*;
import oscP5.*;
import netP5.*;
import java.awt.*;
import java.awt.event.*;
final boolean SERVER = false;
OscP5 oscP5;
int port = 12000;
NetAddress serverLocation = new NetAddress("192.168.2.132", port);
HashMap<String, SensorReading> sensors = new HashMap<String, SensorReading>();
void setup() {
if (!SERVER) {
minim = new Minim(this);
microphoneInput = minim.getLineIn (Minim.STEREO, 512);
}
//Setup server thingies
fillSensorReadings();
if (SERVER)
setupServer();
else
setupClient();
}
void draw() {
if (SERVER)
server_update();
else
client_update();
}
void keyPressed() {
//broadcast();
}
void oscEvent(OscMessage msg) {
if (SERVER)
server_oscEvent(msg);
else
client_oscEvent(msg);
// println("### received an osc message with addrpattern "+msg.addrPattern()+" and typetag "+msg.typetag());
}
void fillSensorReadings() {
addSensor(new Microphone(microphoneInput));
addSensor(new MousePos());
addSensor(new Space());
addSensor(new ScreenSize());
}
void addSensor(SensorReading sr) {
sensors.put(sr.name, sr);
}
void exit() {
if (!SERVER) {
sendDisconnect();
microphoneInput.close();
minim.stop();
}
}