support OSC-string

Dependents:   OSCtoCVConverter

Fork of OSC by Toby Harris

Committer:
casiotone401
Date:
Tue Mar 08 11:50:30 2016 +0000
Revision:
8:73bce95a6853
Parent:
0:fdea65150534
minor change

Who changed what in which revision?

UserRevisionLine numberNew 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 }