Problem with OSC send from Max For Live?
Hi there,
I can read OSC midi from max for live but I can’t read OSC data from max for Live while it is the same port.
I give you a screenshot with Live and OSC “object” of M4Live just that you can see I send good datas from Live with the good port.
And I give the programs to read datas, the first OSC midi and the second OSC data
I have tried many time to restart Processing programs but just first works (it is the one on the top left the screenshot, you can see strings move with midi note).
Thanks for your help ;)
//import the necessary libraries to use send, receive and understand OSC data
import oscP5.*;
//import netP5.*;
// OSC loading stuff
OscP5 o;
//NetAddress myRemoteLocation;
B_String string1, string2, string3, string4, string5, string6, string7, string8;
void setup() {
size(640, 360);
stroke(255);
background(0);
o = new OscP5(this, 2346); //set a port number - it has to be same as in your Max for Live device
//myRemoteLocation = new NetAddress("127.0.0.1", 2346);
string1=new B_String (width*0.1, width*0.3 , width*0.7, width*0.9, height*0.2, 250);
string2=new B_String (width*0.1, width*0.3 , width*0.7, width*0.9, height*0.3, 50);
string3=new B_String (width*0.1, width*0.3 , width*0.7, width*0.9, height*0.4, 150);
string4=new B_String (width*0.1, width*0.3 , width*0.7, width*0.9, height*0.5, 100);
string5=new B_String (width*0.1, width*0.3 , width*0.7, width*0.9, height*0.6, 200);
string6=new B_String (width*0.1, width*0.3 , width*0.7, width*0.9, height*0.7, 0);
string7=new B_String (width*0.1, width*0.3 , width*0.7, width*0.9, height*0.8, 133);
string8=new B_String (width*0.1, width*0.3 , width*0.7, width*0.9, height*0.9, 278);
}
int velocity1, velocity2, velocity3, velocity4, velocity5, velocity6, velocity7, velocity8 = 0;
float ver_move1, ver_move2, ver_move3, ver_move4, ver_move5, ver_move6, ver_move7, ver_move8;
float duration1, duration2, duration3, duration4, duration5, duration6, duration7, duration8;
int note1, note2, note3, note4, note5, note6, note7, note8 = 0;
void draw() {
background(0);
//translate(width/3, height/3);
//noFill();
//stroke(250, 0, 0);
string1.display(ver_move1);
string2.display(ver_move2);
string3.display(ver_move3);
string4.display(ver_move4);
string5.display(ver_move5);
string6.display(ver_move6);
string7.display(ver_move7);
string8.display(ver_move8);
if (ver_move1>0){
ver_move1 = ver_move1 -duration1;}
if (ver_move2>0){
ver_move2 = ver_move2 -duration2;}
if (ver_move3>0){
ver_move3 = ver_move3 -duration3;}
if (ver_move4>0){
ver_move4 = ver_move4 -duration4;}
if (ver_move5>0){
ver_move5 = ver_move5 -duration5;}
if (ver_move6>0){
ver_move6 = ver_move6 -duration6;}
if (ver_move7>0){
ver_move7 = ver_move7 -duration7;}
if (ver_move8>0){
ver_move8 = ver_move8 -duration8;}
ver_move1 = - ver_move1;
ver_move2 = - ver_move2;
ver_move3 = - ver_move3;
ver_move4 = - ver_move4;
ver_move5 = - ver_move5;
ver_move6 = - ver_move6;
ver_move7 = - ver_move7;
ver_move8 = - ver_move8;
}
void oscEvent(OscMessage theMsg) {
if(theMsg.checkAddrPattern("/Velocity1")==true) {
velocity1 = theMsg.get(0).intValue();
ver_move1 = map(velocity1, 0, 127, 0, 60);
}
if(theMsg.checkAddrPattern("/Velocity2")==true) {
velocity2 = theMsg.get(0).intValue();
ver_move2 = map(velocity2, 0, 127, 0, 60);
}
if(theMsg.checkAddrPattern("/Velocity3")==true) {
velocity3 = theMsg.get(0).intValue();
ver_move3 = map(velocity3, 0, 127, 0, 60);
}
if(theMsg.checkAddrPattern("/Velocity4")==true) {
velocity4 = theMsg.get(0).intValue();
ver_move4 = map(velocity4, 0, 127, 0, 60);
}
if(theMsg.checkAddrPattern("/Velocity5")==true) {
velocity5 = theMsg.get(0).intValue();
ver_move5 = map(velocity5, 0, 127, 0, 60);
}
if(theMsg.checkAddrPattern("/Velocity6")==true) {
velocity6 = theMsg.get(0).intValue();
ver_move6 = map(velocity6, 0, 127, 0, 60);
}
if(theMsg.checkAddrPattern("/Velocity7")==true) {
velocity7 = theMsg.get(0).intValue();
ver_move7 = map(velocity7, 0, 127, 0, 60);
}
if(theMsg.checkAddrPattern("/Velocity8")==true) {
velocity8 = theMsg.get(0).intValue();
ver_move8 = map(velocity8, 0, 127, 0, 60);
}
if(theMsg.checkAddrPattern("/Note1")==true) {
note1 = theMsg.get(0).intValue();
duration1 = map(sq(note1), 1, sq(127), 0.05, 0.5);
}
if(theMsg.checkAddrPattern("/Note2")==true) {
note2 = theMsg.get(0).intValue();
duration2 = map(sq(note2), 1, sq(127), 0.05, 0.5);
}
if(theMsg.checkAddrPattern("/Note3")==true) {
note3 = theMsg.get(0).intValue();
duration3 = map(sq(note3), 1, sq(127), 0.05, 0.5);
}
if(theMsg.checkAddrPattern("/Note4")==true) {
note4 = theMsg.get(0).intValue();
duration4 = map(sq(note4), 1, sq(127), 0.05, 0.5);
}
if(theMsg.checkAddrPattern("/Note5")==true) {
note5 = theMsg.get(0).intValue();
duration5 = map(sq(note5), 1, sq(127), 0.05, 0.5);
}
if(theMsg.checkAddrPattern("/Note6")==true) {
note6 = theMsg.get(0).intValue();
duration6 = map(sq(note6), 1, sq(127), 0.05, 0.5);
}
if(theMsg.checkAddrPattern("/Note7")==true) {
note7 = theMsg.get(0).intValue();
duration7 = map(sq(note7), 1, sq(127), 0.05, 0.5);
}
if(theMsg.checkAddrPattern("/Note8")==true) {
note8 = theMsg.get(0).intValue();
duration8 = map(sq(note8), 1, sq(127), 0.05, 0.5);
}
}
/*float log10 (int x) {
return (log(x) / log(10));
}*/
class B_String {
float osc_points, p11, p21, p31, p41, shade;
B_String(float a1, float b1, float c1, float d1, float i, int colour) {
noFill();
//fill(250, 0, 0, 55);
stroke(200, colour, 0);
bezier(a1, i, b1, i, c1, i, d1, i);
osc_points = i;
p11 = a1;
p21 = b1;
p31 = c1;
p41 = d1;
shade = colour;
//fill(0, 0, 0);
}
void display(float velocity) {
noFill();
stroke(200, shade, 0);
bezier(p11, osc_points, p21, osc_points+velocity, p31, osc_points+velocity, p41, osc_points);
bezier(p11, osc_points, p21, osc_points+0.8*velocity, p31, osc_points+0.8*velocity, p41, osc_points);
bezier(p11, osc_points, p21, osc_points+0.6*velocity, p31, osc_points+0.6*velocity, p41, osc_points);
bezier(p11, osc_points, p21, osc_points+0.4*velocity, p31, osc_points+0.4*velocity, p41, osc_points);
bezier(p11, osc_points, p21, osc_points+0.2*velocity, p31, osc_points+0.2*velocity, p41, osc_points);
bezier(p11, osc_points, p21, osc_points, p31, osc_points, p41, osc_points);
}
}
and the one which doesn't work
//import the necessary libraries to use send, receive and understand OSC data
import oscP5.*;
import netP5.*;
// OSC loading stuff
OscP5 o;
//NetAddress myRemoteLocation;
float automation1, automation2, automation3, automation4, automation5, automation6, automation7;
void setup() {
size(640, 360);
automation1=0.5;
o = new OscP5(this, 2346); //set a port number - it has to be same as in your Max for Live device
// myRemoteLocation = new NetAddress("192.168.1.72", 2346); //define address ove which the communication takes place. Requires host address (127.0.0.1 for localhost and the port number previously defined.)
}
void draw() {
background(0);
translate(width/2, height/2);
float ver_move = map(automation1, 0, 1, -300, 300);
float hor_move = map(automation2, 0, 1, -100, 100);
float RColour = map(automation3, 0, 1, 0, 255);
float GColour = map(-automation4, 0, 1, 0, 255);
float BColour = map(automation5, 0, 1, 0, 255);
float XSize = map(automation6, 0, 1, 10, 80);
float YSize = map(automation7, 0, 1, 10, 80);
println (automation1);
fill(RColour,GColour,BColour);
ellipse(ver_move, hor_move, XSize, YSize);
}
//receive and analyse OSC messages
void oscEvent(OscMessage theMsg) {
if(theMsg.checkAddrPattern("/XPosition")==true) {
automation1 = theMsg.get(0).floatValue();
}
if(theMsg.checkAddrPattern("/YPosition")==true) {
automation2 = theMsg.get(0).floatValue();
}
if(theMsg.checkAddrPattern("/RColour")==true) {
automation3 = theMsg.get(0).floatValue();
}
if(theMsg.checkAddrPattern("/GColour")==true) {
automation4 = theMsg.get(0).floatValue();
}
if(theMsg.checkAddrPattern("/BColour")==true) {
automation5 = theMsg.get(0).floatValue();
}
if(theMsg.checkAddrPattern("/XSize")==true) {
automation6 = theMsg.get(0).floatValue();
}
if(theMsg.checkAddrPattern("/YSize")==true) {
automation7 = theMsg.get(0).floatValue();
}
}
Before assuming it's your code, you should check if osc is just conked out on M4L. There is a "known issue", that once you edit a patch in Max and then close, if osc came in to the edited Max patch, Live can no longer use that port. There's a discussion on this on the Max/MSP facebook group and apparently many people have faced this issue. I resorted to hooking up a number box to my udpreceive in M4L so I can just change the port number easily when the patch is not in edit mode and that seems to be working fine.
Hi Iain,
Thanks for your answer.
I didn't edited the patch myself, it's a patch made by Max/Msp for the software Live.
It's called OSC send you can see at the bottom of the previous screenshot.
I changed the port to 2347 in both M4L patch, and I changed the port in the program of Processing (the last program I gave on my previous post).
The patch OSC send doesn't work while the patch OSC MIDI Send work, either with the port 2346 either with 2347.
I don't know how to check if OSC send , send actually something or not.
In Processing, I added a println (automation1) in the draw loop and I have 0.0.
So, if you have an idea...
Start Max standalone, insert udpreceive set to "good" port
and check if it receives anything form that OSC "good" datas device.
If it does, then fix the processing code.
If it does not, fix that device.
When i open the OSC send device in Max 8, I have only thé picture of the device. I don’t havé objects and wires. This Device us designed for M4l, so maybe i can’t open it with Max8?
You did not understand what I mean.
You should send your data from Live,
but open Max Application and make new patch and add udpreceive object
so that you can test if Live is sending OSC messages or not.
But I guess that the problem is that your processing code expects OSC string
which you don't provide.
look at this :if(theMsg.checkAddrPattern("/XPosition")==true)
on that screenshot where you state that you send "good data" to "good port"
it says "Enter OSC Address"
How should that match ?
Hi,
I receive theses datas from OSC midi send and OSC send by changing port receiving data in MAX 8
udpreceiver: binding to port 2346
receivedmess: /Velocity1 100
receivedmess: /Note1 86
receivedmess: /Velocity1 0
receivedmess: /Note1 86
udpreceiver: binding to port 2347
receivedmess: /EnterOSCaddress 0.051317
receivedmess: /EnterOSCaddress 0.051317
receivedmess: /EnterOSCaddress 0.479465
receivedmess: /EnterOSCaddress 0.051317
receivedmess: /EnterOSCaddress 0.051317
Thus, I receive floats into Processing.
You were right.
How can I change the program in Processing?
You need to learn programming in languages you want to use.
Simple as that.
Do you understand Processing code you want to use ?
It asks for the OSC string to recognise the following float value.
In max4live device you need to enter that string instead of
"EnterOSCAddress"
This if condition :if(theMsg.checkAddrPattern("/XPosition")==true
means that you need to enter /XPosition in max4live device in the slot
that you want to use to set variable automation1 in Processing :
if(theMsg.checkAddrPattern("/XPosition")==true) {
automation1= theMsg.get(0).floatValue(); }

then float automation1 will be used for vertical move:float ver_move = map(automation1, 0, 1, -300, 300);
I don't think I can explain this better.
Ok, it's work!
Thanks for you pedagogy. ;)