oscP5
Class OscProperties

java.lang.Object
  extended by oscP5.OscProperties

public class OscProperties
extends Object

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 http://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());
}

Field Summary
static int MULTICAST
           
static boolean OFF
           
static boolean ON
           
static int TCP
           
static int UDP
           
 
Constructor Summary
OscProperties()
          create a new OscProperties Object.
OscProperties(OscEventListener theParent)
           
 
Method Summary
 int datagramSize()
          returns the current size of the datagram bytebuffer.
 String eventMethod()
           
 Vector<OscEventListener> listeners()
           
 int listeningPort()
          returns the port number currently used to receive osc packets.
 int networkProtocol()
          returns the network protocol being used to transmit osc packets.
 NetAddress remoteAddress()
          returns a NetAddress of the remote host you are sending osc packets to.
 boolean sendStatus()
           
 void setDatagramSize(int theSize)
          set the size of the datagrampacket byte buffer.
 void setEventMethod(String theEventMethod)
          set the name of the default event method.
 void setListeningPort(int thePort)
          set port number you are listening for incoming osc packets.
 void setNetworkProtocol(int theProtocol)
          set the network protocol over which osc messages are transmitted.
 void setRemoteAddress(NetAddress theNetAddress)
          set the remote host address.
 void setRemoteAddress(String theHostAddress, int thePort)
          set the remote host address.
 void setSRSP(boolean theFlag)
          SRSP stand for Send and Receive on Same Port.
 boolean srsp()
          you can send and receive at the same port while on a udp con
 String toString()
          prints out the current osc properties settings.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ON

public static final boolean ON
See Also:
Constant Field Values

OFF

public static final boolean OFF
See Also:
Constant Field Values

UDP

public static final int UDP
See Also:
Constant Field Values

MULTICAST

public static final int MULTICAST
See Also:
Constant Field Values

TCP

public static final int TCP
See Also:
Constant Field Values
Constructor Detail

OscProperties

public OscProperties(OscEventListener theParent)

OscProperties

public OscProperties()
create a new OscProperties Object.

Method Detail

listeners

public Vector<OscEventListener> listeners()
Returns:
OscEventListener

sendStatus

public boolean sendStatus()
Returns:
boolean

setRemoteAddress

public void setRemoteAddress(String theHostAddress,
                             int thePort)
set the remote host address. set ip address and port of the host message should be sent to.

Parameters:
theHostAddress - String
thePort - int

setRemoteAddress

public void setRemoteAddress(NetAddress theNetAddress)
set the remote host address. set ip address and port of the host message should be sent to.

Parameters:
theNetAddress - NetAddress

setListeningPort

public void setListeningPort(int thePort)
set port number you are listening for incoming osc packets.

Parameters:
thePort - int

setDatagramSize

public void setDatagramSize(int theSize)
set the size of the datagrampacket byte buffer. the default size is 1536 bytes.

Parameters:
theSize - int

setEventMethod

public void setEventMethod(String theEventMethod)
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"

Parameters:
theEventMethod - String

setNetworkProtocol

public void setNetworkProtocol(int theProtocol)
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.

Parameters:
theProtocol - int

setSRSP

public void setSRSP(boolean theFlag)
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)

Parameters:
theFlag - boolean

srsp

public boolean srsp()
you can send and receive at the same port while on a udp con

Returns:
boolean

listeningPort

public int listeningPort()
returns the port number currently used to receive osc packets.

Returns:
int

remoteAddress

public NetAddress remoteAddress()
returns a NetAddress of the remote host you are sending osc packets to. by default this is null.

Returns:
NetAddress

datagramSize

public int datagramSize()
returns the current size of the datagram bytebuffer.

Returns:
int

eventMethod

public String eventMethod()
Returns:
String

networkProtocol

public int networkProtocol()
returns the network protocol being used to transmit osc packets. returns an int. 0 (UDP), 1 (MULTICAST), 2 (TCP)

Returns:
int

toString

public String toString()
prints out the current osc properties settings.

Overrides:
toString in class Object
Returns:
String


processing library oscP5 by Andreas Schlegel. (c) 2004-2011