How to well sending data to OSCTouch OSC with Processing SOLVED
Hi,
I'm trying float toOSCTouch OSC.
When I send float I can see: OSC /test 6.00000000
but actually, OSC monitor in Live should receive 0.6
If I send 0.5 or any float from 0.0 to 1.0, it works in OSC monitor, and in the M4L OSCTouch OSC and the parameter is well mapped.
So I made a mistake in my Processing program
The problem is when I send in void mousePressed()
myMessage.add((j*1.0));
Could you help me please?
Thanks a lot!
/**
* 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 i=0;
void setup() {
size(400,400);
frameRate(25);
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this,8000);
/* 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(0);
}
void mousePressed() {
i++;
/* in the following different ways of creating osc messages are shown by example */
OscMessage myMessage = new OscMessage("/test");
// OscMessage myMessage1 = new OscMessage("/testBis");
float j= i/10;
myMessage.add((j*1.0)); /* add an int to the osc message */
myMessage.add((0.9)); /* add an int to the osc message */
// myMessage.add(int (2*i-1)); /* add an int to the osc message */
print((j));
// println(2*i-1);
/* send the message */
oscP5.send(myMessage, myRemoteLocation);
// oscP5.send(myMessage1, 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());
}
maybe you want to constrain output to 0. - 1. ?
if yes , then
myMessage.add((j%1));
here one example sending 2 inverted values with 0.1 increament :
import oscP5.*;
import netP5.*;
OscP5 oscP5;
int i;
void setup() {size(400,400); oscP5 = new OscP5(this,8000);}
void draw() {background(0);}
void mousePressed() {i++;
OscMessage myMessage = new OscMessage("/test");
float j= i/10.; // want float ? then divide using float !
myMessage.add((j%1)); myMessage.add((abs(j%1-1)));
oscP5.send(myMessage, "127.0.0.1",8000);
}
Thank you