-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlatencyTest_GPIO_OSC_sPi
More file actions
56 lines (47 loc) · 1.54 KB
/
latencyTest_GPIO_OSC_sPi
File metadata and controls
56 lines (47 loc) · 1.54 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
// this tests the latency between a sample playing in sonic pi, and a GPIO pin on the pi turned on at the same time
// sPi puts out OSC which processing catches, and turns on a GPIO pin.
// I'm getting 704ms, which is useless for triggering sounds, anyway.
import processing.io.*;
import oscP5.*;
import netP5.*;
int outPin = 26;
int pinHighTime = 50;
long startPinHigh;
OscP5 oscP5;
// NetAddress myBroadcastLocation; // if you want to send to pi also
void setup() {
background(0);
frameRate(100);
GPIO.pinMode(outPin, GPIO.OUTPUT);
GPIO.digitalWrite(outPin, GPIO.LOW);
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() {
if (millis() > startPinHigh + pinHighTime) {
GPIO.digitalWrite(outPin, GPIO.LOW);
}
}
void oscEvent(OscMessage theOscMessage) { // When you receive a message…
println(theOscMessage);
GPIO.digitalWrite(outPin, GPIO.HIGH);
println("on");
startPinHigh = millis();
println(startPinHigh);
// 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
sample :perc_snap
d = rrand(50,90)
s = d.to_s
puts s
use_osc "192.168.1.159", 8000 # change to your ip address (ifconfig will tell you)
osc "/hello/world "+s
sleep 1
end
*/