Skip to content

Instantly share code, notes, and snippets.

@santiago
Created July 16, 2011 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santiago/1085903 to your computer and use it in GitHub Desktop.
Save santiago/1085903 to your computer and use it in GitHub Desktop.
import oscP5.*;
import netP5.*;
OscP5 oscP5;
float[] data;
boolean started;
NetAddress myBroadcastLocation;
void setup() {
size(400,400);
frameRate(60);
/* create a new instance of oscP5.
* 12000 is the port number you are listening for incoming osc messages.
*/
oscP5 = new OscP5(this,12000);
/* create a new NetAddress. a NetAddress is used when sending osc messages
* with the oscP5.send method.
*/
/* the address of the osc broadcast server */
// myBroadcastLocation = new NetAddress("192.168.2.19",10002);
}
void draw() {
background(0xffffff);
if(started) {
for(int i=0; i<16; i++) {
fill(13,123,56);
rect(i*10,0,10,data[i]*10000);
fill(9,100,200);
rect(0,i*10,data[i]*10000,10);
rect(400-i*10,0,10,data[i]*10000);
}
}
}
/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
/* get and print the address pattern and the typetag of the received OscMessage */
// println("### received an osc message with addrpattern "+theOscMessage.addrPattern()+" and typetag "+theOscMessage.typetag());
started= true;
theOscMessage.print();
data= new float[16];
for(int i=0; i<16; i++) {
data[i]= theOscMessage.get(i).floatValue();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment