-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecieveOSC_from_sonicPi_basic
More file actions
57 lines (49 loc) · 1.34 KB
/
recieveOSC_from_sonicPi_basic
File metadata and controls
57 lines (49 loc) · 1.34 KB
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
// This sketch runs on the receiving computer which will play the received notes
import oscP5.*;
import netP5.*;
OscP5 oscP5;
// NetAddress myBroadcastLocation; // if you want to send to pi also
void setup() {
background(0);
frameRate(100);
size (1,1); // We don’t need to see anything.
oscP5 = new OscP5(this,8000); // The port to the source Sonic which the source processing app sends
// myBroadcastLocation = new NetAddress("127.0.0.1",4559); // The port on which Sonic Pi listens to incoming messages.
}
void draw() {
}
void oscEvent(OscMessage theOscMessage) { // When you receive a message…
println(theOscMessage);
// println(theOscMessage.arguments());
// oscP5.send(theOscMessage, myBroadcastLocation); //send it to Sonic Pi on this machine.
}
// in sonicPi, use this to send OSC
live_loop :foo do
play 60
use_osc "192.168.1.11", 8000
osc "/hello/world"
sleep 1
end
// to send a number from sPi, use to_s to convert to string, then add to osc message
live_loop :foo do
play 60
d = rrand(50,90)
s = d.to_s
puts s
use_osc "192.168.1.11", 8000
osc "/hello/world "+s
sleep 1
end
// send current tick number like this, resets when gets to 20
live_loop :clickOut do
#play 60
e = tick(:click)
s = e.to_s
puts s
use_osc "192.168.1.11", 8000
osc "/click "+s
sleep 1
if e >= 19
tick_reset(:click)
end
end