Get array data from Max/Msp with OSC protocol

Hi everybody,
I want to send an array of vertices from max/msp to openFrameworks, but ofxOsc has just those functions: getArgAsFloat(), getArgAsInt32(), getArgAsString(), wich can’t be used to receive an array. What could I use?
Thank you for any answer

It depends what you are sending from max, most likely floats. You can find out what it is from inside ofxOsc using

ofxOscMessage m;
for( int i=0; i<m.getNumArgs(); i++ ){
    m.getArgTypeName()
}

This part

m.getNumArgs()

will be the length of your incoming array (if you are selecting for the correct address), most likely it will go through each vertex x and then y position and then to the next vertex but it can depend on how you constructed this in max.

Thank you for your anwer fresla : )
I know that I’m sending floats from Max (a list of floats), but I wonder how can I iterate through them in oF.
For example if I want to fill an ofVec3f I was thinking about this:

    if(m.getAddress() == "vboVertices") {
        for(int i = 0; i < m.getNumArgs(); i++){
            vboVertices[i] = m.getArgAsFloat(i);
        }

But this is illegal because m.getArgAsFloat() can’t fill three vertices. In this case I should do something like this?

    if(m.getAddress() == "vboVertices") {
            int j = 0;
            for(int i = 0; i < m.getNumArgs(); i+=3){
               vboVertices[j].x = m.getArgAsFloat(i);
               vboVertices[j].y = m.getArgAsFloat(i+1);
               vboVertices[j].z = m.getArgAsFloat(i+2);
               j++;
            }
        }

This unless there is a way to get a complete list from max and pass it like a single argument to an ofVec3f class.

Not really, the way that max handles lists under the hood (letting you pass a whole list) is doing pretty much what you are doing manually. If you add this code to the OSC class, or make a helper class that does this for you, you will always have the functionality in your code and can treat it like this from now on. You will be able to add this to any project you make.

Fred

2 Likes