Step 4Receive OSC Messages in Processing
In order to receive OSC messages, an interrupt/event handler method is required. The simplest way to debug OSC event handling is to simply printout whatever is received using code like this:
void oscEvent(OscMessage theOscMessage)
{
println(theOscMessage.toString());
}
To get the value(s) of a message employ the following command in the oscEvent function:
float myVariable = theOscMessage.get(0).floatValue();
In the case of Mimbo, the OSC Event handler looks like this:
void oscEvent(OscMessage theOscMessage)
{
// This runs whenever there is a new OSC message
String addr = theOscMessage.addrPattern(); // Creates a string out of the OSC message
if (addr.indexOf("/accxyz") != -1) {
last_accx = accx;
last_accy = accy;
accx = theOscMessage.get(0).floatValue();
accy = theOscMessage.get(1).floatValue();
accz = theOscMessage.get(2).floatValue();
}
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|












































