61 lines
1.4 KiB
Plaintext
61 lines
1.4 KiB
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 (chkmsg(msgIn, "/slider_group1")) {
|
|
setBeatDecay(msgIn.get(0).floatValue());
|
|
return;
|
|
}
|
|
if (chkmsg(msgIn, "/slider_group2")) {
|
|
setAmpBeginFraction(msgIn.get(0).floatValue());
|
|
return;
|
|
}
|
|
if (chkmsg(msgIn, "/knob_group1")) {
|
|
setAmpStart(msgIn.get(0).floatValue());
|
|
return;
|
|
}
|
|
if (chkmsg(msgIn, "/knob_group2")) {
|
|
setAmpStep(msgIn.get(0).floatValue());
|
|
return;
|
|
}
|
|
}
|
|
|
|
float last_beat = 0;
|
|
void oscSendBeatValue(float beat) {
|
|
if ( beat != last_beat ) {
|
|
OscMessage msg = new OscMessage("/osc_beat_val");
|
|
msg.add(beat);
|
|
oscObj.send(msg, shaderNetAddress);
|
|
last_beat = beat;
|
|
}
|
|
}
|
|
|
|
boolean chkmsg(OscMessage msg, String name) {
|
|
return msg.checkAddrPattern(name) && msg.checkTypetag("f");
|
|
}
|