Send matrix over osc?

Hi,

I want to send a matrix over osc to another machine on my local network, in order for that to use it in max/msp. I am thinking of just building a list of values from ofFbo and getColor and then sending it off to him like that. However, there are probably much better and smarter ways of doing this out there…?

I would make a small fbo with just the portion of the screen you want to send, convert to ofpixels and send all the data via osc, binary blob to parse there. once you know the channel order and number of channels you can parse there.
I remember some limitation of the packet size, maybe 1500 bytes depending on your router.
depending on the size of your matrix you’ll want to cut in sections and remount there. the osc packet itself will use some bytes, if you use plain UDP you can use more bytes for pixel colors.

1 Like

alternatively, you could try ndi, there are some addons for openFrameworks as well as some max/jit packages.

3 Likes

Thanks, both! NDI looks, at a first glance, like it might just do the trick. The binary blob idea might also just work (and may be less overkill than NDI seems to be). Will give both of these alternatives a good look.

@dimitre could you maybe give me a short example of how you would stuff a binary blob into an osc message?

I managed to patch together a solution that seems to work by doing this:


    fbo.readToPixels(pixels);
    pixels.resize(downSampledWidth, downSampledHeight);


    ofxOscMessage m;
    m.setAddress("/fbo");
    for(size_t i = 0; i<pixels.size(); i++){
        m.addCharArg(pixels[i]);
    }
    sender.sendMessage(m);

I can’t for the life of me figure out how to copy an ofFbo to an ofBuffer, so I can’t get the binary blob thing working yet.

Great! some suggestions: I would try to resize in fbo. maybe creating two fbos, one with the final output (downSampleWidth / downSampledHeight) and drawing one inside another. this way your resize operation happens on the GPU instead of the CPU.
so you just read to pixels, and then you can transfer to the osc message.

I havent tested this but you can look at
You don’t have to iterate over all pixels.
Try to add this data
pixels.getData()

As this message parameter
ofxOscArgBlob

So you will work with only one osc parameter in your message containing all the pixels

You can try to cast to another type
or make an ofBuffer and use set to set the buffer data equal to ofPixels data.

Thanks a lot! Will take a look at it again tomorrow, to see if I can make it work.

1 Like