Created
May 20, 2016 09:13
-
-
Save gansaibow/2672bb76809caef94fd3bc4e76026a13 to your computer and use it in GitHub Desktop.
送信したOSCメッセージの確認する受信処理を用意する ref: http://qiita.com/gansaibow/items/fcae51cff691b6b84905
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; | |
int receivePort = 12345; | |
String sendIP = "127.0.0.1"; | |
int sendPort = 12001; | |
void setup() { | |
size(400,400); | |
frameRate(25); | |
/* start oscP5, listening for incoming messages at port 12000 */ | |
oscP5 = new OscP5(this,receivePort); | |
/* 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(sendIP,sendPort); | |
} | |
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()); | |
theOscMessage.print(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment