oscP5
Class OscBundle

java.lang.Object
  extended by oscP5.OscPatcher
      extended by oscP5.OscPacket
          extended by oscP5.OscBundle

public class OscBundle
extends OscPacket

Osc Bundles are collections of Osc Messages. use bundles to send multiple osc messages to one destination. the OscBundle timetag is supported for sending but not for receiving yet.

+Example
/**
 * oscP5bundle by andreas schlegel
 * an osc broadcast server.
 * example shows how to create and send osc bundles. 
 * oscP5 website at http://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() {
  /* create an osc bundle */
  OscBundle myBundle = new OscBundle();
  
  /* createa new osc message object */
  OscMessage myMessage = new OscMessage("/test");
  myMessage.add("abc");
  
  /* add an osc message to the osc bundle */
  myBundle.add(myMessage);
  
  /* reset and clear the myMessage object for refill. */
  myMessage.clear();
  
  /* refill the osc message object again */
  myMessage.setAddrPattern("/test2");
  myMessage.add("defg");
  myBundle.add(myMessage);
  
  myBundle.setTimetag(myBundle.now() + 10000);
  /* send the osc bundle, containing 2 osc messages, to a remote location. */
  oscP5.send(myBundle, 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());
  print(" typetag: "+theOscMessage.typetag());
  println(" timetag: "+theOscMessage.timetag());
}

Constructor Summary
OscBundle()
          instantiate a new OscBundle object.
 
Method Summary
 void add(OscMessage theOscMessage)
          add an osc message to the osc bundle.
 void clear()
          clear and reset the osc bundle for reusing.
 byte[] getBytes()
           
 OscMessage getMessage(int theIndex)
          request an osc message inside the osc bundle array,
static long now()
          returns the current time in milliseconds.
 void remove(int theIndex)
          remove an OscMessage from an OscBundle.
 void remove(OscMessage theOscMessage)
           
 void setTimetag(long theTime)
          set the timetag of an osc bundle.
 int size()
          get the size of the osc bundle array which contains the osc messages.
 byte[] timetag()
          returns a timetag as byte array.
 
Methods inherited from class oscP5.OscPacket
address, netaddress, netAddress, port, tcpConnection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OscBundle

public OscBundle()
instantiate a new OscBundle object.

Method Detail

add

public void add(OscMessage theOscMessage)
add an osc message to the osc bundle.

Parameters:
theOscMessage - OscMessage

clear

public void clear()
clear and reset the osc bundle for reusing.

+Example
/**
 * oscP5bundle by andreas schlegel
 * an osc broadcast server.
 * example shows how to create and send osc bundles. 
 * oscP5 website at http://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() {
  /* create an osc bundle */
  OscBundle myBundle = new OscBundle();
  
  /* createa new osc message object */
  OscMessage myMessage = new OscMessage("/test");
  myMessage.add("abc");
  
  /* add an osc message to the osc bundle */
  myBundle.add(myMessage);
  
  /* reset and clear the myMessage object for refill. */
  myMessage.clear();
  
  /* refill the osc message object again */
  myMessage.setAddrPattern("/test2");
  myMessage.add("defg");
  myBundle.add(myMessage);
  
  myBundle.setTimetag(myBundle.now() + 10000);
  /* send the osc bundle, containing 2 osc messages, to a remote location. */
  oscP5.send(myBundle, 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());
  print(" typetag: "+theOscMessage.typetag());
  println(" timetag: "+theOscMessage.timetag());
}

remove

public void remove(int theIndex)
remove an OscMessage from an OscBundle.

Parameters:
theIndex - int

remove

public void remove(OscMessage theOscMessage)
Parameters:
theOscMessage - OscMessage

getMessage

public OscMessage getMessage(int theIndex)
request an osc message inside the osc bundle array,

Parameters:
theIndex - int
Returns:
OscMessage

size

public int size()
get the size of the osc bundle array which contains the osc messages.

Returns:
int
+Example
/**
 * oscP5bundle by andreas schlegel
 * an osc broadcast server.
 * example shows how to create and send osc bundles. 
 * oscP5 website at http://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() {
  /* create an osc bundle */
  OscBundle myBundle = new OscBundle();
  
  /* createa new osc message object */
  OscMessage myMessage = new OscMessage("/test");
  myMessage.add("abc");
  
  /* add an osc message to the osc bundle */
  myBundle.add(myMessage);
  
  /* reset and clear the myMessage object for refill. */
  myMessage.clear();
  
  /* refill the osc message object again */
  myMessage.setAddrPattern("/test2");
  myMessage.add("defg");
  myBundle.add(myMessage);
  
  myBundle.setTimetag(myBundle.now() + 10000);
  /* send the osc bundle, containing 2 osc messages, to a remote location. */
  oscP5.send(myBundle, 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());
  print(" typetag: "+theOscMessage.typetag());
  println(" timetag: "+theOscMessage.timetag());
}

setTimetag

public void setTimetag(long theTime)
set the timetag of an osc bundle. timetags are used to synchronize events and execute events at a given time in the future or immediately. timetags can only be set for osc bundles, not for osc messages. oscP5 supports receiving timetags, but does not queue messages for execution at a set time.

Parameters:
theTime - long
+Example
/**
 * oscP5bundle by andreas schlegel
 * an osc broadcast server.
 * example shows how to create and send osc bundles. 
 * oscP5 website at http://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() {
  /* create an osc bundle */
  OscBundle myBundle = new OscBundle();
  
  /* createa new osc message object */
  OscMessage myMessage = new OscMessage("/test");
  myMessage.add("abc");
  
  /* add an osc message to the osc bundle */
  myBundle.add(myMessage);
  
  /* reset and clear the myMessage object for refill. */
  myMessage.clear();
  
  /* refill the osc message object again */
  myMessage.setAddrPattern("/test2");
  myMessage.add("defg");
  myBundle.add(myMessage);
  
  myBundle.setTimetag(myBundle.now() + 10000);
  /* send the osc bundle, containing 2 osc messages, to a remote location. */
  oscP5.send(myBundle, 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());
  print(" typetag: "+theOscMessage.typetag());
  println(" timetag: "+theOscMessage.timetag());
}

now

public static long now()
returns the current time in milliseconds. use with setTimetag.

Returns:
long

timetag

public byte[] timetag()
returns a timetag as byte array.

Returns:
byte[]

getBytes

public byte[] getBytes()
Specified by:
getBytes in class OscPacket
Returns:
byte[]


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