summaryrefslogtreecommitdiffstats
path: root/libraries/oscP5/examples
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2015-12-31 03:34:08 +0100
committerDavid Runge <dave@sleepmap.de>2015-12-31 03:34:08 +0100
commit589e6c881bd2cf11e8615e9c1bf8cb4012293bad (patch)
tree407d617ed861a61d64e64f7d581052f90b10e981 /libraries/oscP5/examples
parent6a713ba6966eee4cf7bb9fb9e1513918fc94b528 (diff)
downloadprocessing-sketchbook-589e6c881bd2cf11e8615e9c1bf8cb4012293bad.tar.gz
processing-sketchbook-589e6c881bd2cf11e8615e9c1bf8cb4012293bad.tar.bz2
processing-sketchbook-589e6c881bd2cf11e8615e9c1bf8cb4012293bad.tar.xz
processing-sketchbook-589e6c881bd2cf11e8615e9c1bf8cb4012293bad.zip
libraries/oscP5: Adding oscP5 library for OSC capabilities.
Diffstat (limited to 'libraries/oscP5/examples')
-rw-r--r--libraries/oscP5/examples/oscP5broadcastClient/oscP5broadcastClient.pde73
-rw-r--r--libraries/oscP5/examples/oscP5broadcastTester/oscP5broadcastTester.pde27
-rw-r--r--libraries/oscP5/examples/oscP5broadcaster/oscP5broadcaster.pde73
-rw-r--r--libraries/oscP5/examples/oscP5bundle/oscP5bundle.pde69
-rw-r--r--libraries/oscP5/examples/oscP5flush/oscP5flush.pde38
-rw-r--r--libraries/oscP5/examples/oscP5message/oscP5message.pde55
-rw-r--r--libraries/oscP5/examples/oscP5multicast/oscP5multicast.pde51
-rw-r--r--libraries/oscP5/examples/oscP5oscArgument/oscP5oscArgument.pde45
-rw-r--r--libraries/oscP5/examples/oscP5parsing/oscP5parsing.pde65
-rw-r--r--libraries/oscP5/examples/oscP5plug/oscP5plug.pde82
-rw-r--r--libraries/oscP5/examples/oscP5properties/oscP5properties.pde72
-rw-r--r--libraries/oscP5/examples/oscP5sendReceive/oscP5sendReceive.pde51
-rw-r--r--libraries/oscP5/examples/oscP5tcp/oscP5tcp.pde59
13 files changed, 760 insertions, 0 deletions
diff --git a/libraries/oscP5/examples/oscP5broadcastClient/oscP5broadcastClient.pde b/libraries/oscP5/examples/oscP5broadcastClient/oscP5broadcastClient.pde
new file mode 100644
index 0000000..56fb843
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5broadcastClient/oscP5broadcastClient.pde
@@ -0,0 +1,73 @@
+/**
+ * oscP5broadcastClient by andreas schlegel
+ * an osc broadcast client.
+ * an example for broadcast server is located in the oscP5broadcaster exmaple.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+
+OscP5 oscP5;
+
+/* a NetAddress contains the ip address and port number of a remote location in the network. */
+NetAddress myBroadcastLocation;
+
+void setup() {
+ size(400,400);
+ frameRate(25);
+
+ /* create a new instance of oscP5.
+ * 12000 is the port number you are listening for incoming osc messages.
+ */
+ oscP5 = new OscP5(this,12000);
+
+ /* create a new NetAddress. a NetAddress is used when sending osc messages
+ * with the oscP5.send method.
+ */
+
+ /* the address of the osc broadcast server */
+ myBroadcastLocation = new NetAddress("127.0.0.1",32000);
+}
+
+
+void draw() {
+ background(0);
+}
+
+
+void mousePressed() {
+ /* create a new OscMessage with an address pattern, in this case /test. */
+ OscMessage myOscMessage = new OscMessage("/test");
+ /* add a value (an integer) to the OscMessage */
+ myOscMessage.add(100);
+ /* send the OscMessage to a remote location specified in myNetAddress */
+ oscP5.send(myOscMessage, myBroadcastLocation);
+}
+
+
+void keyPressed() {
+ OscMessage m;
+ switch(key) {
+ case('c'):
+ /* connect to the broadcaster */
+ m = new OscMessage("/server/connect",new Object[0]);
+ oscP5.flush(m,myBroadcastLocation);
+ break;
+ case('d'):
+ /* disconnect from the broadcaster */
+ m = new OscMessage("/server/disconnect",new Object[0]);
+ oscP5.flush(m,myBroadcastLocation);
+ break;
+
+ }
+}
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+ /* get and print the address pattern and the typetag of the received OscMessage */
+ println("### received an osc message with addrpattern "+theOscMessage.addrPattern()+" and typetag "+theOscMessage.typetag());
+ theOscMessage.print();
+}
diff --git a/libraries/oscP5/examples/oscP5broadcastTester/oscP5broadcastTester.pde b/libraries/oscP5/examples/oscP5broadcastTester/oscP5broadcastTester.pde
new file mode 100644
index 0000000..440e7cd
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5broadcastTester/oscP5broadcastTester.pde
@@ -0,0 +1,27 @@
+import controlP5.*;
+
+
+ControlP5 controlP5;
+
+int myColorBackground = color(0,0,0);
+
+int knobValue = 100;
+
+void setup() {
+ size(400,400);
+ smooth();
+ controlP5 = new ControlP5(this);
+ controlP5.addKnob("knob",100,200,128,100,160,40);
+ controlP5.addKnob("knobValue",0,255,128,100,240,40);
+}
+
+void draw() {
+ background(myColorBackground);
+ fill(knobValue);
+ rect(0,0,width,100);
+}
+
+void knob(int theColor) {
+ myColorBackground = color(theColor);
+ println("a knob event. setting background to "+theColor);
+}
diff --git a/libraries/oscP5/examples/oscP5broadcaster/oscP5broadcaster.pde b/libraries/oscP5/examples/oscP5broadcaster/oscP5broadcaster.pde
new file mode 100644
index 0000000..1cbd638
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5broadcaster/oscP5broadcaster.pde
@@ -0,0 +1,73 @@
+/**
+ * oscP5broadcaster by andreas schlegel
+ * an osc broadcast server.
+ * osc clients can connect to the server by sending a connect and
+ * disconnect osc message as defined below to the server.
+ * incoming messages at the server will then be broadcasted to
+ * all connected clients.
+ * an example for a client is located in the oscP5broadcastClient exmaple.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddressList myNetAddressList = new NetAddressList();
+/* listeningPort is the port the server is listening for incoming messages */
+int myListeningPort = 32000;
+/* the broadcast port is the port the clients should listen for incoming messages from the server*/
+int myBroadcastPort = 12000;
+
+String myConnectPattern = "/server/connect";
+String myDisconnectPattern = "/server/disconnect";
+
+
+void setup() {
+ oscP5 = new OscP5(this, myListeningPort);
+ frameRate(25);
+}
+
+void draw() {
+ background(0);
+}
+
+void oscEvent(OscMessage theOscMessage) {
+ /* check if the address pattern fits any of our patterns */
+ if (theOscMessage.addrPattern().equals(myConnectPattern)) {
+ connect(theOscMessage.netAddress().address());
+ }
+ else if (theOscMessage.addrPattern().equals(myDisconnectPattern)) {
+ disconnect(theOscMessage.netAddress().address());
+ }
+ /**
+ * if pattern matching was not successful, then broadcast the incoming
+ * message to all addresses in the netAddresList.
+ */
+ else {
+ oscP5.send(theOscMessage, myNetAddressList);
+ }
+}
+
+
+ private void connect(String theIPaddress) {
+ if (!myNetAddressList.contains(theIPaddress, myBroadcastPort)) {
+ myNetAddressList.add(new NetAddress(theIPaddress, myBroadcastPort));
+ println("### adding "+theIPaddress+" to the list.");
+ } else {
+ println("### "+theIPaddress+" is already connected.");
+ }
+ println("### currently there are "+myNetAddressList.list().size()+" remote locations connected.");
+ }
+
+
+
+private void disconnect(String theIPaddress) {
+if (myNetAddressList.contains(theIPaddress, myBroadcastPort)) {
+ myNetAddressList.remove(theIPaddress, myBroadcastPort);
+ println("### removing "+theIPaddress+" from the list.");
+ } else {
+ println("### "+theIPaddress+" is not connected.");
+ }
+ println("### currently there are "+myNetAddressList.list().size());
+ }
diff --git a/libraries/oscP5/examples/oscP5bundle/oscP5bundle.pde b/libraries/oscP5/examples/oscP5bundle/oscP5bundle.pde
new file mode 100644
index 0000000..a747db2
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5bundle/oscP5bundle.pde
@@ -0,0 +1,69 @@
+/**
+ * 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());
+}
diff --git a/libraries/oscP5/examples/oscP5flush/oscP5flush.pde b/libraries/oscP5/examples/oscP5flush/oscP5flush.pde
new file mode 100644
index 0000000..e6e8147
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5flush/oscP5flush.pde
@@ -0,0 +1,38 @@
+ /**
+ * oscP5flush by andreas schlegel
+ * example shows how to send osc messages without having to instantiate an oscP5 object.
+ * this can be useful if you are not listening for incoming messages and you
+ * want to avoid to have the additional oscP5 thread running listening for incoming
+ * message (which you wont need if you are only sending messages).
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+
+NetAddress myRemoteLocation;
+void setup() {
+ size(400,400);
+ frameRate(25);
+ /* set up a remote location */
+ myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+
+void draw() {
+ background(0);
+}
+
+
+void mousePressed() {
+ /* create a new OscMessage with an address pattern, in this case /test. */
+ OscMessage myOscMessage = new OscMessage("/test");
+
+ /* add a value (an integer) to the OscMessage */
+ myOscMessage.add(100);
+
+ /* send the OscMessage to the remote location.
+ */
+ OscP5.flush(myOscMessage,myRemoteLocation);
+}
diff --git a/libraries/oscP5/examples/oscP5message/oscP5message.pde b/libraries/oscP5/examples/oscP5message/oscP5message.pde
new file mode 100644
index 0000000..b19f38f
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5message/oscP5message.pde
@@ -0,0 +1,55 @@
+/**
+ * oscP5message by andreas schlegel
+ * example shows how to create osc messages.
+ * 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() {
+ /* 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 */
+ myMessage.add(12.34); /* add a float to the osc message */
+ myMessage.add("some text"); /* add a string to the osc message */
+ myMessage.add(new byte[] {0x00, 0x01, 0x10, 0x20}); /* add a byte blob to the osc message */
+ myMessage.add(new int[] {1,2,3,4}); /* add an int array 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());
+}
diff --git a/libraries/oscP5/examples/oscP5multicast/oscP5multicast.pde b/libraries/oscP5/examples/oscP5multicast/oscP5multicast.pde
new file mode 100644
index 0000000..26d6dc1
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5multicast/oscP5multicast.pde
@@ -0,0 +1,51 @@
+/**
+ * oscP5multicast by andreas schlegel
+ * example shows how to send osc via a multicast socket.
+ * what is a multicast? http://en.wikipedia.org/wiki/Multicast
+ * ip multicast ranges and uses:
+ * 224.0.0.0 - 224.0.0.255 Reserved for special Òwell-knownÓ multicast addresses.
+ * 224.0.1.0 - 238.255.255.255 Globally-scoped (Internet-wide) multicast addresses.
+ * 239.0.0.0 - 239.255.255.255 Administratively-scoped (local) multicast addresses.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+
+void setup() {
+ size(400,400);
+ frameRate(25);
+ /* create a new instance of oscP5 using a multicast socket. */
+ oscP5 = new OscP5(this,"239.0.0.1",7777);
+}
+
+
+void draw() {
+ background(0);
+}
+
+
+void mousePressed() {
+ /* create a new OscMessage with an address pattern, in this case /test. */
+ OscMessage myOscMessage = new OscMessage("/test");
+
+ /* add a value (an integer) to the OscMessage */
+ myOscMessage.add(100);
+
+ /* send the OscMessage to the multicast group.
+ * the multicast group netAddress is the default netAddress, therefore
+ * you dont need to specify a NetAddress to send the osc message.
+ */
+ oscP5.send(myOscMessage);
+}
+
+
+/* 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());
+}
diff --git a/libraries/oscP5/examples/oscP5oscArgument/oscP5oscArgument.pde b/libraries/oscP5/examples/oscP5oscArgument/oscP5oscArgument.pde
new file mode 100644
index 0000000..dd67ff0
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5oscArgument/oscP5oscArgument.pde
@@ -0,0 +1,45 @@
+/**
+ * oscP5oscArgument by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an alternative way to parse messages.
+ * 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 = new NetAddress("127.0.0.1",12000);
+ /* send an OSC message to this sketch */
+ oscP5.send("/test",new Object[] {new Integer("1"), new Float(2.0),"test string."}, myRemoteLocation);
+
+}
+
+void draw() {
+ background(0);
+}
+
+void oscEvent(OscMessage theOscMessage) {
+ /* check if theOscMessage has the address pattern we are looking for. */
+ if(theOscMessage.checkAddrPattern("/test")==true) {
+ /* check if the typetag is the right one. */
+ if(theOscMessage.checkTypetag("ifs")) {
+ /* parse theOscMessage and extract the values from the osc message arguments. */
+ int firstValue = theOscMessage.get(0).intValue(); // get the first osc argument
+ float secondValue = theOscMessage.get(1).floatValue(); // get the second osc argument
+ String thirdValue = theOscMessage.get(2).stringValue(); // get the third osc argument
+ print("### received an osc message /test with typetag ifs.");
+ println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+ return;
+ }
+ }
+ println("### received an osc message. with address pattern "+
+ theOscMessage.addrPattern()+" typetag "+ theOscMessage.typetag());
+}
diff --git a/libraries/oscP5/examples/oscP5parsing/oscP5parsing.pde b/libraries/oscP5/examples/oscP5parsing/oscP5parsing.pde
new file mode 100644
index 0000000..abb035d
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5parsing/oscP5parsing.pde
@@ -0,0 +1,65 @@
+/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * 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 a new osc message object */
+ OscMessage myMessage = new OscMessage("/test");
+
+ myMessage.add(123); /* add an int to the osc message */
+ myMessage.add(12.34); /* add a float to the osc message */
+ myMessage.add("some text"); /* add a string to the osc message */
+
+ /* send the message */
+ oscP5.send(myMessage, myRemoteLocation);
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+ /* check if theOscMessage has the address pattern we are looking for. */
+
+ if(theOscMessage.checkAddrPattern("/test")==true) {
+ /* check if the typetag is the right one. */
+ if(theOscMessage.checkTypetag("ifs")) {
+ /* parse theOscMessage and extract the values from the osc message arguments. */
+ int firstValue = theOscMessage.get(0).intValue();
+ float secondValue = theOscMessage.get(1).floatValue();
+ String thirdValue = theOscMessage.get(2).stringValue();
+ print("### received an osc message /test with typetag ifs.");
+ println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+ return;
+ }
+ }
+ println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
diff --git a/libraries/oscP5/examples/oscP5plug/oscP5plug.pde b/libraries/oscP5/examples/oscP5plug/oscP5plug.pde
new file mode 100644
index 0000000..5b72973
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5plug/oscP5plug.pde
@@ -0,0 +1,82 @@
+/**
+ * oscP5plug by andreas schlegel
+ * example shows how to use the plug service with oscP5.
+ * the concept of the plug service is, that you can
+ * register methods in your sketch to which incoming
+ * osc messages will be forwareded automatically without
+ * having to parse them in the oscEvent method.
+ * that a look at the example below to get an understanding
+ * of how plug works.
+ * 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);
+
+ /* osc plug service
+ * osc messages with a specific address pattern can be automatically
+ * forwarded to a specific method of an object. in this example
+ * a message with address pattern /test will be forwarded to a method
+ * test(). below the method test takes 2 arguments - 2 ints. therefore each
+ * message with address pattern /test and typetag ii will be forwarded to
+ * the method test(int theA, int theB)
+ */
+ oscP5.plug(this,"test","/test");
+}
+
+
+public void test(int theA, int theB) {
+ println("### plug event method. received a message /test.");
+ println(" 2 ints received: "+theA+", "+theB);
+}
+
+
+void draw() {
+ background(0);
+}
+
+
+void mousePressed() {
+ /* createan osc message with address pattern /test */
+ OscMessage myMessage = new OscMessage("/test");
+
+ myMessage.add(123); /* add an int to the osc message */
+ myMessage.add(456); /* add a second 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) {
+ /* with theOscMessage.isPlugged() you check if the osc message has already been
+ * forwarded to a plugged method. if theOscMessage.isPlugged()==true, it has already
+ * been forwared to another method in your sketch. theOscMessage.isPlugged() can
+ * be used for double posting but is not required.
+ */
+ if(theOscMessage.isPlugged()==false) {
+ /* print the address pattern and the typetag of the received OscMessage */
+ println("### received an osc message.");
+ println("### addrpattern\t"+theOscMessage.addrPattern());
+ println("### typetag\t"+theOscMessage.typetag());
+ }
+}
diff --git a/libraries/oscP5/examples/oscP5properties/oscP5properties.pde b/libraries/oscP5/examples/oscP5properties/oscP5properties.pde
new file mode 100644
index 0000000..a0756fe
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5properties/oscP5properties.pde
@@ -0,0 +1,72 @@
+/**
+ * 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());
+}
diff --git a/libraries/oscP5/examples/oscP5sendReceive/oscP5sendReceive.pde b/libraries/oscP5/examples/oscP5sendReceive/oscP5sendReceive.pde
new file mode 100644
index 0000000..0159a63
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5sendReceive/oscP5sendReceive.pde
@@ -0,0 +1,51 @@
+/**
+ * oscP5sendreceive by andreas schlegel
+ * example shows how to send and receive osc messages.
+ * 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() {
+ /* 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());
+}
diff --git a/libraries/oscP5/examples/oscP5tcp/oscP5tcp.pde b/libraries/oscP5/examples/oscP5tcp/oscP5tcp.pde
new file mode 100644
index 0000000..90ee312
--- /dev/null
+++ b/libraries/oscP5/examples/oscP5tcp/oscP5tcp.pde
@@ -0,0 +1,59 @@
+/**
+ * oscP5tcp by andreas schlegel
+ * example shows how to use the TCP protocol with oscP5.
+ * what is TCP? http://en.wikipedia.org/wiki/Transmission_Control_Protocol
+ * in this example both, a server and a client are used. typically
+ * this doesnt make sense as you usually wouldnt communicate with yourself
+ * over a network. therefore this example is only to make it easier to
+ * explain the concept of using tcp with oscP5.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+
+OscP5 oscP5tcpServer;
+
+OscP5 oscP5tcpClient;
+
+NetAddress myServerAddress;
+
+void setup() {
+ /* create an oscP5 instance using TCP listening @ port 11000 */
+ oscP5tcpServer = new OscP5(this, 11000, OscP5.TCP);
+
+ /* create an oscP5 instance using TCP.
+ * the remote address is 127.0.0.1 @ port 11000 = the server from above
+ */
+ oscP5tcpClient = new OscP5(this, "127.0.0.1", 11000, OscP5.TCP);
+}
+
+
+void draw() {
+ background(0);
+}
+
+
+void mousePressed() {
+ /* the tcp client sends a message to the server it is connected to.*/
+ oscP5tcpClient.send("/test", new Object[] {new Integer(1)});
+}
+
+
+void keyPressed() {
+ /* check how many clients are connected to the server. */
+ println(oscP5tcpServer.tcpServer().getClients().length);
+}
+
+void oscEvent(OscMessage theMessage) {
+ /* in this example, both the server and the client share this oscEvent method */
+ System.out.println("### got a message " + theMessage);
+ if(theMessage.checkAddrPattern("/test")) {
+ /* message was send from the tcp client */
+ OscMessage m = new OscMessage("/response");
+ m.add("server response: got it");
+ /* server responds to the client's message */
+ oscP5tcpServer.send(m,theMessage.tcpConnection());
+ }
+}