An Open Sound Control library for the mbed, created to be compatible with Recotana's OSCClass library (http://recotana.com) for the Arduino with Ethernet shield. It also uses parts of the OSC Transceiver(Sender/Receiver) code by xshige written by: Alvaro Cassinelli, October 2011 tweaked by: Toby Harris / *spark audio-visual, March 2012
example-processing.h@0:fdea65150534, 2012-04-15 (annotated)
- Committer:
- tobyspark
- Date:
- Sun Apr 15 15:50:42 2012 +0000
- Revision:
- 0:fdea65150534
mbedOSC__spk as program to OSC as library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tobyspark | 0:fdea65150534 | 1 | /* EXAMPLE SEND/RECEIVE on PROCESSING: |
tobyspark | 0:fdea65150534 | 2 | |
tobyspark | 0:fdea65150534 | 3 | // oscP5sendreceive by andreas schlegel |
tobyspark | 0:fdea65150534 | 4 | // example shows how to send and receive osc messages. |
tobyspark | 0:fdea65150534 | 5 | // oscP5 website at http://www.sojamo.de/oscP5 |
tobyspark | 0:fdea65150534 | 6 | |
tobyspark | 0:fdea65150534 | 7 | */ |
tobyspark | 0:fdea65150534 | 8 | |
tobyspark | 0:fdea65150534 | 9 | import oscP5.*; |
tobyspark | 0:fdea65150534 | 10 | import netP5.*; |
tobyspark | 0:fdea65150534 | 11 | |
tobyspark | 0:fdea65150534 | 12 | OscP5 oscP5; |
tobyspark | 0:fdea65150534 | 13 | NetAddress myRemoteLocation; |
tobyspark | 0:fdea65150534 | 14 | |
tobyspark | 0:fdea65150534 | 15 | void setup() { |
tobyspark | 0:fdea65150534 | 16 | size(400,400); |
tobyspark | 0:fdea65150534 | 17 | frameRate(25); |
tobyspark | 0:fdea65150534 | 18 | // start oscP5, listening for incoming messages at port 12000 |
tobyspark | 0:fdea65150534 | 19 | oscP5 = new OscP5(this,12000); |
tobyspark | 0:fdea65150534 | 20 | |
tobyspark | 0:fdea65150534 | 21 | // myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters, |
tobyspark | 0:fdea65150534 | 22 | // an ip address and a port number. myRemoteLocation is used as parameter in |
tobyspark | 0:fdea65150534 | 23 | // oscP5.send() when sending osc packets to another computer, device, |
tobyspark | 0:fdea65150534 | 24 | // application. usage see below. for testing purposes the listening port |
tobyspark | 0:fdea65150534 | 25 | // and the port of the remote location address are the same, hence you will |
tobyspark | 0:fdea65150534 | 26 | // send messages back to this sketch. |
tobyspark | 0:fdea65150534 | 27 | myRemoteLocation = new NetAddress("10.0.0.2",10000); |
tobyspark | 0:fdea65150534 | 28 | } |
tobyspark | 0:fdea65150534 | 29 | |
tobyspark | 0:fdea65150534 | 30 | |
tobyspark | 0:fdea65150534 | 31 | void draw() { |
tobyspark | 0:fdea65150534 | 32 | background(0); |
tobyspark | 0:fdea65150534 | 33 | } |
tobyspark | 0:fdea65150534 | 34 | |
tobyspark | 0:fdea65150534 | 35 | void mousePressed() { |
tobyspark | 0:fdea65150534 | 36 | // in the following different ways of creating osc messages are shown by example |
tobyspark | 0:fdea65150534 | 37 | OscMessage myMessage = new OscMessage("/mbed/test1"); |
tobyspark | 0:fdea65150534 | 38 | |
tobyspark | 0:fdea65150534 | 39 | myMessage.add(123); // add an int to the osc message |
tobyspark | 0:fdea65150534 | 40 | |
tobyspark | 0:fdea65150534 | 41 | // send the message |
tobyspark | 0:fdea65150534 | 42 | oscP5.send(myMessage, myRemoteLocation); |
tobyspark | 0:fdea65150534 | 43 | } |
tobyspark | 0:fdea65150534 | 44 | |
tobyspark | 0:fdea65150534 | 45 | |
tobyspark | 0:fdea65150534 | 46 | // incoming osc message are forwarded to the oscEvent method. |
tobyspark | 0:fdea65150534 | 47 | void oscEvent(OscMessage theOscMessage) { |
tobyspark | 0:fdea65150534 | 48 | // print the address pattern and the typetag of the received OscMessage |
tobyspark | 0:fdea65150534 | 49 | print("### received an osc message."); |
tobyspark | 0:fdea65150534 | 50 | print(" addrpattern: "+theOscMessage.addrPattern()); |
tobyspark | 0:fdea65150534 | 51 | println(" typetag: "+theOscMessage.typetag()); |
tobyspark | 0:fdea65150534 | 52 | } |