OSC - Open Sound Control
DynamoBen
Posts: 366
A while back (2011ish) someone posted propOSC which implemented Open Sound Control for the prop. While the thread still exists the attachment which contained the code is missing. Anyone have a copy? Alternatively does anyone have working OSC code? I'd rather not reinvent the wheel if its already been done. Thanks!
Comments
Unfortunately I have a 2009 "all obex" only..
That would have been very nice...
Massimo
In case it's not downloadable from the forum I have a copy of this...
Massimo
Thanks. I downloaded it the other day and am evaluating whether it will work for my application.
To give you some background for the transmit code the OSC address is added (stored to a buffer location) and then type tags and arguments are appended (buffer for each) and the the entire assembled string can be requested (each buffer is appended to new buffer location and pointer is returned). This allows any transport method to be used from serial to UDP.
On the receive side I'm stuck on how best to return the data contained in a packet. Right now I'm taking a packet and storing it to three buffers: Address, Type Tags, and Arguments. Returning the Address is pretty easy I just return the pointer to the buffer I stored it to, but returning the arguments are tricky especially when multiple arguments types are mixed together (IE an int32, a string, another int32, another string). One thought was to request data based on type tag position. Using my example position 0 would be an int32, position 1 would be a string, etc. But by doing this I would have to hunt through the buffer by type to find the data and then return it. This seems inefficient and not very elegant. Is this the best way to do it? Thoughts on a better way?
I think I've done something similar with a Modbus project which used different data types for different registers. When the program first started up, I'd have it build an identification array which would contain the type code.
(The registers in this example were all even numbers.) Edit: Doesn't matter. I changed the code to use both odd and even values.
The data types were defined with constants:
The data type was initially assumed to be an integer but then the list of floating point registers and the list of string registers were read and appropriate types filled into the "dataTypes" array.
Each of the constants listed of course corresponded to a unique register number.
The value of "dataTypes[registerNumber]" could then be used to identify what type of data the register contained.
I'm sure there's a technical term for this technique. I imagine database software produces lists like these (and then some).
Did I understand the question correctly? If so, maybe the above would be useful.
He has no email in his profile. By his IP address, he is located in Canada.
It's a huge bummer, I also tried posting to the original thread thinking he might get an email notification. But no response.
I wonder if Parallax might have a backup of the file...doubt it but one could hope.
No, but the data included a header with the size of the packet and the starting register number. I would use something like:
The array "dataType" had previously been filled with the appropriate values so it acted as a fast lookup table.
I'm not sure if the above code would apply to an OSC packet or not. Looking at the OSC page you linked to, it appears there's an identifier which includes the data type. I'm not sure if I'm reading that correctly or not though.
Could you give a couple examples of data you could receive? Am I correct in thinking the data is sent as ASCII characters?
I don't think it made it to the OBEX, I think it was just posted to the forum.
Spec has examples via hyperlinks, the website isn't loading for me otherwise I would embed a link here.
UPDATE: It's loading here are some message examples: http://opensoundcontrol.org/spec-1_0-examples#addressparts