OscProperties

description
osc properties are used to start oscP5 with more specific settings. osc properties have to be passed to oscP5 in the constructor when starting a new instance of oscP5.
+Example
/**
 * oscP5properities by andreas schlegel
 * example shows how to use osc properties. 
 * if you need more specific settings for your osc session,
 * osc properties serves your needs.
 * oscP5 website at https://www.sojamo.de/oscP5
 */
import oscP5.*;
import netP5.*;

OscP5 oscP5;

void setup() {
  size(400,400);
  frameRate(25);

  /* create a new osc properties object */
  OscProperties properties = new OscProperties();
  
  /* set a default NetAddress. sending osc messages with no NetAddress parameter 
   * in oscP5.send() will be sent to the default NetAddress.
   */
  properties.setRemoteAddress("127.0.0.1",12000);
  
  /* the port number you are listening for incoming osc packets. */
  properties.setListeningPort(12000);
  
  
  /* Send Receive Same Port is an option where the sending and receiving port are the same.
   * this is sometimes necessary for example when sending osc packets to supercolider server.
   * while both port numbers are the same, the receiver can simply send an osc packet back to
   * the host and port the message came from.
   */
  properties.setSRSP(OscProperties.ON);
  
  /* set the datagram byte buffer size. this can be useful when you send/receive
   * huge amounts of data, but keep in mind, that UDP is limited to 64k
  */
  properties.setDatagramSize(1024);
  
  /* initialize oscP5 with our osc properties */
  oscP5 = new OscP5(this,properties);    
  
  /* print your osc properties */
  println(properties.toString());
}



void mousePressed() {
  /* create a new osc message with address pattern /test */
  OscMessage myMessage = new  OscMessage("/test");
  myMessage.add(200);
  
  /* send the osc message to the default netAddress, set in the OscProperties above.*/
  oscP5.send(myMessage);
}


void draw() {
  background(0);  
}



/* 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
OscProperties(theParent);
OscProperties();
Methods
datagramSize ( )
returns the current size of the datagram bytebuffer.
listeningPort ( )
returns the port number currently used to receive osc packets.
networkProtocol ( )
returns the network protocol being used to transmit osc packets. returns an int. 0 (UDP), 1 (MULTICAST), 2 (TCP)
remoteAddress ( )
returns a NetAddress of the remote host you are sending osc packets to. by default this is null.
setDatagramSize ( )
set the size of the datagrampacket byte buffer. the default size is 1536 bytes.
setEventMethod ( )
set the name of the default event method. the event method is the method to which incoming osc messages are forwarded. the default name for the event method is "oscEvent"
setListeningPort ( )
set port number you are listening for incoming osc packets.
setNetworkProtocol ( )
set the network protocol over which osc messages are transmitted. options are OscProperties.UDP and OscProperties.MULTICAST the network protocol can only be set before initializing oscP5.
setRemoteAddress ( )
set the remote host address. set ip address and port of the host message should be sent to.
setSRSP ( )
SRSP stand for Send and Receive on Same Port. by default osc packets are not received and sent by the same port. if you need to send and receive on the same port call setSRSP(OscProperties.ON)
srsp ( )
you can send and receive at the same port while on a udp con
toString ( )
prints out the current osc properties settings.
usage
Web & Application
related