-
Notifications
You must be signed in to change notification settings - Fork 0
/
rRobot.ck
88 lines (78 loc) · 1.9 KB
/
rRobot.ck
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
// rRobot.ck
// Eric Heep, October 2015
// ~
// example code that uses the Gamelan
// framework to control the robots in the Machine Lab
// groove receiver
OscRecv recv;
6449 => recv.port;
recv.listen();
// robot OSC
OscSend xmit;
xmit.setHost("chuckServer.local", 50000);
// create an address in the receiver, store in new variable
recv.event( "/plork/synch/clock, i i" ) @=> OscEvent oe;
// get pane
AudicleGroove.pane() @=> AudiclePane @ pane;
// dat groove
[[1.0, 0.2, 0.3, 0.2, 0.4, 0.1, 0.2, 0.1],
[0.5, 0.1, 0.3, 0.2, 0.4, 0.1, 0.2, 0.1],
[0.8, 0.1, 0.3, 0.2, 0.5, 0.1, 0.2, 0.1],
[0.4, 0.1, 0.3, 0.2, 0.3, 0.1, 0.2, 0.1]] @=> float mygains[][];
// vars
int x, y, val;
while (true) {
// wait for event to arrive
oe => now;
// grab the next message from the queue.
while (oe.nextMsg() != 0) {
// get x and y
oe.getInt() => x;
oe.getInt() => y;
// set glow
pane.setglow( x, y, 1 );
// get value
pane.getvalue( x, y ) => val;
// play the thing
if (val > 0) {
spork ~ play(val, (127 * mygains[y][x]) $ int);
}
}
}
fun void play(int val, int vel) {
if (val == 1) {
note("/drumBot", 0, vel);
}
if (val == 2) {
note("/drumBot", 1, vel);
}
if (val == 3) {
for (int i; i < 10; i++) {
note("/clappers", i, vel);
10::ms => now;
}
}
if (val == 4) {
for (10 => int i; i < 20; i++) {
note("/clappers", i, vel);
10::ms => now;
}
}
if (val == 5) {
note("/ganapati", 1, vel);
}
if (val == 6) {
note("/ganapati", 2, vel);
}
if (val == 7) {
note("/devibot", 4, vel);
}
if (val == 8) {
note("/devibot", 5, vel);
}
}
fun void note(string addr, int num, int vel) {
xmit.startMsg(addr, "i i");
xmit.addInt(num);
xmit.addInt(vel);
}