What sketch code can listen for incoming osc messages so my software sends effect as variable "X". and Processing makes circles with coordinates "X"?
in
Contributed Library Questions
•
3 years ago
I'm new to this and I'm interested in sync my music up with processing so I can make like visual effects that are in
sync with the beat if that makes sense
this the code i am working with so far
any help will be very appreciated : )
/**
* oscP5message by andreas schlegel
* example shows how to create osc messages.
* oscP5 website at http://www.sojamo.de/oscP5
*/
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
void setup() {
size(400,400);
frameRate(25);
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this,8001);
/* 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("127.0.0.1",8000);
}
void draw() {
background(550);
}
void mousePressed() {
/* in the following different ways of creating osc messages are shown by
example */
OscMessage myMessage = new OscMessage("/anibone");
myMessage.add("knee");
float mx = mouseX; float nmx = norm(mx,0,400);
myMessage.add(nmx); /* add a float 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());
}
(O_o)
sync with the beat if that makes sense
this the code i am working with so far
any help will be very appreciated : )
/**
* oscP5message by andreas schlegel
* example shows how to create osc messages.
* oscP5 website at http://www.sojamo.de/oscP5
*/
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
void setup() {
size(400,400);
frameRate(25);
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this,8001);
/* 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("127.0.0.1",8000);
}
void draw() {
background(550);
}
void mousePressed() {
/* in the following different ways of creating osc messages are shown by
example */
OscMessage myMessage = new OscMessage("/anibone");
myMessage.add("knee");
float mx = mouseX; float nmx = norm(mx,0,400);
myMessage.add(nmx); /* add a float 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());
}
(O_o)
1