Hello everyone,
it’s been a few weeks since I’m trying to send the values of some variables from Processing to Max Msp through the Oscp5 library. Being a newcomer in programming with java and processing, and not being a computer scientist, but a composer, I hope the question below is not unpleasant.
I enclose the test sketch below:
//Davide Martiello sketch "trytopasssomedata"
import netP5.*;
import oscP5.*;
OscP5 oscP5;
NetAddress oscDestination;
OscMessage myMessage;
int numeri;
int a;
int b;
int value;
void setup() {
size(10, 10);
frameRate(30);
oscP5 = new OscP5(this, 7374);
oscDestination = new NetAddress("127.0.0.1", 7374);
oscP5.plug(this, "a", "/a");
oscP5.plug(this, "b", "/b");
}
//public void a(int value);
//public void b(int value);
void draw() {
int[] numeri = new int[3];
numeri[0] = 20; //assegno un valore al primo elemento dell'Array
numeri[1] = 50; //assegno un valore al secondo elemento dell'Array
numeri[2] = 1; //assegno un valore al terzo elemento dell'Array
int a = numeri[0] + numeri[1]; <-----
int b = numeri[1] + numeri[2]; <-----
println(b);
println(a);
Ganzo();
}
void Ganzo() {
OscMessage myMessage = new OscMessage ("/a");
myMessage.add(a);
OscMessage myMessage1 = new OscMessage ("/b");
myMessage1.add(b);
oscP5.send(myMessage, oscDestination);
oscP5.send(myMessage1, oscDestination);
}
The two platforms communicate well and in real time without any latency.
I can see the values within the processing console, but I cannot see the values of the variables “a” and “b” within Max Msp.
What appears on Max’s console is “received message:” to “0” b "0 , and I understand why:
I have to assign a value to the messages sent with the myMessage function, but I have already done it just above where I have indicated with this sign (<—).
Is it possible that Processing does not see the value already assigned to the function?
What I think I need to do is to tell the function myMessage.add (a) that a is the sum of two integers, and that it must take those values and bring them as they are in Max Msp, but I have not yet succeeded to do it.
I hope someone can help me because I cannot find a solution.
Thank you and I hope you can help me.
Cordially,
Davide