OSC from Max/Msp

jersmi's picture

Anyone sending OSC data from max to QC? How can structures be received / sorted? Trying to receive x position / y position / rotation from approx. 100 separate items. These are essentially separate "particles", small images interacting with physics on screen. So i'd like to use an iterator on the QC side instead of wiring up separate sprites but not sure how to set addresses, sort structures, etc. i should use a 1-d structure? So far I am successfully using the qcOSC plugin to avoid values continuously / unexpectedly jumping to 0. Any advice welcome.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

gtoledo3's picture
Re: OSC from Max/Msp

I think I would try to send each data/string as one lane.... so send one x, one y, one z, one r, one g, etc., from each osc output port.

I would try to format the data from max as a bunch of x values (or whatever value you need) with a space in between each value. So, to derive a QCStruct that's

1:.2 2:.4 3:-.05

you would want Max to send a string that's

.2 .4 -.05

Then, one would take the OSC output and run it through a string components patch left on default. By default, it will look for every space, and break the string into a one lane data structure. You can then use the iterator to sort through.

Maybe that's weird, but I think since you can't receive structure, I think it's a really good route to bring in strings like this, and I'm pretty sure Max has the tools you need to send the data that way.

As far as setting ports, your OSC sender in Max should have some kind of sender port setting, and then match that up in QC. I haven't used that specific plugin, and it's being sort of finicky for me for some reason (I think b/c I'm in 64 bit at the moment...), I've just used the normal OSC.

I've attached a composition that substitutes insert splitters with strings written with spaces, to simulate.

PreviewAttachmentSize
string component structures.qtz10.6 KB

jersmi's picture
Re: OSC from Max/Msp

Thank you so much. Really helpful, GT.

btw, QC's built-in OSC Receiver was behaving exactly the same way that prompted the creator of qcOSC to make his patch (as noted on the plugin webpage at hexler.net). known issue, for sure. and his patch works well -- auto-populates, too, which is nice.

jersmi's picture
Re: OSC from Max/Msp

One more question, if you don't mind. I need to "trigger" initial values from QC to max via OSC, then have max "pick up" the values and takeover, sending the data back to QC via OSC (my initial question). I actually only need to send initial values to max once in the process per set of values, but i may need a good handful of comps. I'm trying to think of a method. I have a patch with an interaction inside an iterator, thinking i could move around sprites then send as some kind of structure or array to max, but i don't quite know how i'd get the data from this to max. any thoughts would be appreciated.

PreviewAttachmentSize
SpriteInterIter000.qtz12.45 KB

livio's picture
Re: OSC from Max/Msp

Hi, I'm also using qcOSC which works smooth for me (OSC sender jumps to 0s as well here, unless slowing down to 120-150ms the communication).

My problem is that when compiling any composition with qcOSC in it to an application Quartz Builder crashes, or when it happen to compile the resulting application crashes.

Known issue? Any solution?

For the moment I had to go back to OSC sender and smooth the values to make them "continuous", but it's a work around that doesn't suite much the visual result..

dust's picture
Re: OSC from Max/Msp

ok so i made 2 patches that demo a simple osc/upd connection between qc and max. what these patches do is send mouse data from qc as a float type to max and then parse, and pack the messages to send back to qc as a float structure.

max doesn't care about the address or name space it will pass udp info regardless of namespace. for instance you can send a floating point number via udp to your self and max will interpret that number for you. thats ok if your sending one value but if your sending more than one thing to the same port you need to make a name space in order to differentiate your values.

luckily you can not send or receive anything with the stock osc patches in qc without using a name space. the name space is arbitrary. it is just a string. like "/foo" or "foo" it doesn't matter if you have "/" or not. there are various ways of parsing the data from qc in max. i like to use the "match" object. then unpack the data. using the identifier "nn" with your match will let you match a name space and pass just the values you want.

so it looks like (match foo nn). what this does is scan the udp port for a message with name space foo then passes the message through the match object. you then do an an (unpack s 0.) this will unpack the name space to the left port and the floating point data to the right port for you to use how you want.

the s in unpack stand for string and the 0. means floating point in max terms. that means you send a structure of floats to max and unpack them like (unpack s 0.0 0.0 0.0) this will unpack lets say (foo x y z). xyz being floating point values. you wouldn't use xyz though because those are strings you would use 0.0 to unpack a floating point. to keep track of things you can say (unpack foo 0.0 0.0 0.0) meaning you don't have to use the symbol s any string will tell unpack to unpack char data for that port.

so that is getting data from qc into max. next you want to send it back to qc. remember you need a name space to send to qc. there are various ways to prepend your name space to a message to send to qc. you could pack your list to send as floating points then (prepend set) that to a message box then band that message box into a (prepend foo) to prepend your namespace to your list. in the demo patches i'm using a "zl" object to join my name space with a packed list. there are a ton of ways to do this in max it all depends on what your comfortable with. i mean you can pass variables through message boxes with the $ as well. or you could append the list to your name space instead of prepending etc..

so to get floating point data the only way to get that into qc is pack as floats as qc will only accept a structure of floats. otherwise you have to do what george is saying and send everything to qc as a string then explode the string components in qc. depending on the source of that data this may be ideal or may take a few extra steps to pack your floating point numbers into a string.

see attachment. all it does is send mouse data to max and back to qc to move a circle around.

PreviewAttachmentSize
Patches.zip7.42 KB
OSC_qc.png
OSC_qc.png274.22 KB
UDP_Max.png
UDP_Max.png27.14 KB

jersmi's picture
Re: OSC from Max/Msp

So if the message is packed as floats in max then QC won't insert 0's? dust, do you know why QC does that?

dust's picture
Re: OSC from Max/Msp

im sorry i'm not sure what you mean. i'm thinking yes qc will input a default 0 to a float structure if no data is present. if that is what you mean. if your sending something and getting 0 you might want to make sure your ports are bound. i think qc gives you a message when it is receiving data. try just packing a few number boxes in max and see if you get the same values in qc ?