summaryrefslogtreecommitdiffstats
path: root/libraries/oscP5/examples/oscP5multicast
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/oscP5multicast
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/oscP5multicast')
-rw-r--r--libraries/oscP5/examples/oscP5multicast/oscP5multicast.pde51
1 files changed, 51 insertions, 0 deletions
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());
+}