Created
July 16, 2011 01:45
-
-
Save santiago/1085903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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