36 lines
921 B
Plaintext
36 lines
921 B
Plaintext
import oscP5.*;
|
|
import netP5.*;
|
|
|
|
OscP5 oscObj;
|
|
final int RECEIVEPORT = 13337;
|
|
final int SENDPORT = 4242;
|
|
NetAddress shaderNetAddress;
|
|
|
|
// sends osc messages
|
|
void setupOsc() {
|
|
oscObj = new OscP5(this, RECEIVEPORT);
|
|
shaderNetAddress = new NetAddress("127.0.0.1", SENDPORT);
|
|
}
|
|
|
|
void drawOsc() {
|
|
if (frameCount % 5 == 0) {
|
|
OscMessage msg = new OscMessage("/osc_beat_val");
|
|
msg.add(getBeatDetectNormalized());
|
|
oscObj.send(msg, shaderNetAddress);
|
|
}
|
|
}
|
|
|
|
// reacts to osc messages
|
|
void oscEvent(OscMessage msgIn) {
|
|
//print("### received an osc message.");
|
|
//print(" addrpattern: "+msgIn.addrPattern());
|
|
//println(" typetag: "+msgIn.typetag());
|
|
if (msgIn.checkAddrPattern("/beat_decay")==true) {
|
|
if (msgIn.checkTypetag("f")) {
|
|
myBeatMax = max(int(BEAT_MAX*msgIn.get(0).floatValue()), 1);
|
|
//println(" myBeatMax: "+myBeatMax+" f: "+msgIn.get(0).floatValue());
|
|
return;
|
|
}
|
|
}
|
|
}
|