Hello guys!
I would like to send data to max (float and int).
I made a small sketch based on the example of the library oscP5, but I don’t know at all, if we can send several int like that. There is a problem with floats.
I read this in the monitor, I’m not sure it a good sign.
[2020/3/24 17:31:17] PROCESS @ OscP5 stopped.
[2020/3/24 17:31:17] PROCESS @ UdpClient.openSocket udp socket initialized.
[2020/3/24 17:31:18] ERROR @ UdpServer.start() IOException, couldnt create new DatagramSocket @ port 12000 java.net.BindException: Address already in use (Bind failed)
[2020/3/24 17:31:23] INFO @ OscP5 is running. you (192.168.1.105) are listening @ port 12000
I will put the patch of Max Msp later.
Thank you to all !
/**
* 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;
float speedA, speedB, speedC, speedD, speedE;
int numberofrevolutionA, numberofrevolutionB, numberofrevolutionC, numberofrevolutionD, numberofrevolutionE;
void setup() {
size(400,400);
frameRate(25);
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this,12000);
speedA=0.01;
speedB=0.02;
speedC=0.03;
speedD=0.04;
speedE=0.05;
numberofrevolutionA =0;
numberofrevolutionB =1;
numberofrevolutionC =2;
numberofrevolutionD =3;
numberofrevolutionE =4;
/* 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",12000);
}
void draw() {
background(0);
}
void mousePressed() {
numberofrevolutionA = numberofrevolutionA+1; numberofrevolutionB = numberofrevolutionB+1; numberofrevolutionC = numberofrevolutionC+1;
speedA=speedA+0.01; speedB=speedB+0.01; speedC=speedC+0.01;
/* in the following different ways of creating osc messages are shown by example */
OscMessage myMessage = new OscMessage("/test");
println (numberofrevolutionA, numberofrevolutionB, numberofrevolutionC );
println (speedA, speedB, speedC);
myMessage.add(numberofrevolutionA, numberofrevolutionA, numberofrevolutionB, numberofrevolutionC ); /* add an int to the osc message */
// myMessage.add(speedA, speedB, speedC);
/* 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());
}
/**
* 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;
float speedA, speedB, speedC, speedD, speedE;
int numberofrevolutionA, numberofrevolutionB, numberofrevolutionC, numberofrevolutionD, numberofrevolutionE;
void setup() {
size(400,400);
frameRate(25);
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this,12000);
speedA=0.01;
speedB=0.02;
speedC=0.03;
speedD=0.04;
speedE=0.05;
numberofrevolutionA =0;
numberofrevolutionB =1;
numberofrevolutionC =2;
numberofrevolutionD =3;
numberofrevolutionE =4;
/* 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",12000);
}
void draw() {
background(0);
}
void mousePressed() {
numberofrevolutionA = numberofrevolutionA+1; numberofrevolutionB = numberofrevolutionB+1; numberofrevolutionC = numberofrevolutionC+1;
speedA=speedA+0.01; speedB=speedB+0.01; speedC=speedC+0.01;
/* in the following different ways of creating osc messages are shown by example */
OscMessage myMessage = new OscMessage("/test");
println (numberofrevolutionA, numberofrevolutionB, numberofrevolutionC );
println (speedA, speedB, speedC);
myMessage.add(numberofrevolutionA, numberofrevolutionA, numberofrevolutionB, numberofrevolutionC ); /* add an int to the osc message */
// myMessage.add(speedA, speedB, speedC);
/* 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());
}