From 589e6c881bd2cf11e8615e9c1bf8cb4012293bad Mon Sep 17 00:00:00 2001 From: David Runge Date: Thu, 31 Dec 2015 03:34:08 +0100 Subject: libraries/oscP5: Adding oscP5 library for OSC capabilities. --- .../examples/oscP5multicast/oscP5multicast.pde | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 libraries/oscP5/examples/oscP5multicast/oscP5multicast.pde (limited to 'libraries/oscP5/examples/oscP5multicast') 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()); +} -- cgit v1.2.3-54-g00ecf