OscP5

description
oscP5 is an osc implementation for the programming environment processing. osc is the acronym for open sound control, a network protocol developed at cnmat, uc berkeley. open sound control is a protocol for communication among computers, sound synthesizers, and other multimedia devices that is optimized for modern networking technology and has been used in many application areas. for further specifications and application implementations please visit the official osc site.
+Example
/**
 * oscP5sendreceive by andreas schlegel
 * example shows how to send and receive osc messages.
 * oscP5 website at https://www.sojamo.de/oscP5
 */
 
import oscP5.*;
import netP5.*;
  
OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
  size(400,400);
  frameRate(25);
  /* start oscP5, listening for incoming messages at port 12000 */
  oscP5 = new OscP5(this,12000);
  
  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
   * an ip address and a port number. myRemoteLocation is used as parameter in
   * oscP5.send() when sending osc packets to another computer, device, 
   * application. usage see below. for testing purposes the listening port
   * and the port of the remote location address are the same, hence you will
   * send messages back to this sketch.
   */
  myRemoteLocation = new NetAddress("127.0.0.1",12000);
}


void draw() {
  background(0);  
}

void mousePressed() {
  /* in the following different ways of creating osc messages are shown by example */
  OscMessage myMessage = new OscMessage("/test");
  
  myMessage.add(123); /* add an int to the osc message */

  /* send the message */
  oscP5.send(myMessage, myRemoteLocation); 
}


/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
  /* print the address pattern and the typetag of the received OscMessage */
  print("### received an osc message.");
  print(" addrpattern: "+theOscMessage.addrPattern());
  println(" typetag: "+theOscMessage.typetag());
}
constructors
OscP5(theParent, theProperties);
OscP5(theParent, theAddress, thePort, theMode);
OscP5(theParent, theReceiveAtPort, theMode);
OscP5(theParent, theReceiveAtPort);
OscP5(theParent, theAddress, thePort);
parameters
theParentObject 
thePropertiesOscProperties 
theAddressString 
thePortint 
theModeint 
theReceiveAtPortint 
Fields
MULTICAST
a static variable used when creating an oscP5 instance with a sepcified network protocol.
TCP
a static variable used when creating an oscP5 instance with a sepcified network protocol.
UDP
a static variable used when creating an oscP5 instance with a sepcified network protocol.
Methods
flush ( )
a static method to send an OscMessage straight out of the box without having to instantiate oscP5.
netInfo ( )
netinfo() returns an instance of a NetInfo Object from which you can get LAN and WAN information.
plug ( )
osc messages can be automatically forwarded to a specific method of an object. the plug method can be used to by-pass parsing raw osc messages - this job is done for you with the plug mechanism. you can also use the following array-types int[], float[], String[]. (but only as on single parameter e.g. somemethod(int[] theArray) {} ).
properties ( )
returns the current properties of oscP5.
send ( )
the send method offers a lot of possibilities. have a look in the send documentation.
setLogStatus ( )
oscP5 has a logging mechanism which prints out processes, warnings and errors into the console window. e.g. turn off the error log with setLogStatus(Logger.ERROR, Logger.OFF);
setTimeToLive ( )
set timeToLive of a multicast packet.
stop ( )
stop oscP5 and close open Sockets.
tcpClient ( )
return the instance of the running TCP client if in TCP mode.
tcpServer ( )
return the instance of the running TCP server if in TCP mode.
version ( )
get the current version of oscP5.
usage
Application