UDP/OSC message serialization format

jeffomatic's icon

udpsend serializes Max messages into an "OSC compatible UDP packet". I'd like to try to do the same from an external program; i.e., I want to send commands to Max via UDP via a program I create myself. I'm guessing this has been done before, but are there any publicly-available examples or documentation for doing this?

vektoren's icon

Thats funny, because I tryed the same yesterday :) I wrote a little C# program with Visual Studio Professional... but I can't send any message that Max understand. I tryed many OSC examples but no one works :(

If I found an solution, I will add that information here :)

Jan M's icon

Hi, maybe this helps: Andy Schmeder wrote a PHP librabry that can fromat and send UDP/OSC data.
http://andy.schmeder.net/software
And attached is a short code example in php how i send udp/osc from a server/website to max.

Best jan

2450.2387.webtomax.zip
zip
$Adam's icon

If you do NOT need OSC, just pure UDP send/receive, you could try [sadam.udpSender] and [sadam.udpReceiver] from the sadam Library:

Hope this helps,
Ádám

vektoren's icon

Okay, thanks to Jan I found a solution :) Thank you. I have to test a little bit around and write then a little how-to => I attach the how-to here ;)

jeffomatic's icon

I've been playing around with the official OSC tools a little bit, and it seems like udpreceive can receive strings sent by the command-line sendOSC utility. I've tried doing the equivalent in custom code using the C OSC client library (OSC-client.h), but I haven't had time to resolve some formatting errors I get when I send messages this way.

In any case, even if that succeeds, I'd still like to know how Max serializes its data into OSC messages. If I'm not able to figure that out, then another option would be to write a parser in Max that takes string data from OSC messages and translates them into some action or data structure that is native to Max.

vektoren's icon

Give me some time, jeffomatic. I think my howto would help you to do the job without any OSC lib. I hope that I find time to finish that document in the next days...

vektoren's icon

Okay, here is version 1. In the next version I want to describe howto send numbers. Version 1 covers just text messages :) With this information you are able to communicate with Max from any programming language that can send byte arrays over UDP :)

Max Patch
Copy patch and select New From Clipboard in Max.

Here my Max code to receive:

2454.HowtoOSCUDPMaxMSP.pdf
pdf
vektoren's icon

Version 2: I added an UML diagram for building a text message :)

2455.HowtoOSCUDPMaxMSP.pdf
pdf
vektoren's icon

Here we are: Version 3 :) I added the information how to send numbers (integers and also floats) to Max. In chapter 3 I provide a quick and dirty implementation with Microsoft C# 4.0 to show how to do that :)

Have fun!

Next goal: How to receive messages and numbers from Max MSP.

2459.HowtoOSCUDPMaxMSP.pdf
pdf
nick rothwell | project cassiel's icon

Max's UDP objects support pretty standard, if simple, OSC. There are a few Java OSC libraries out there (which makes them usable from Python, Clojure, Ruby and so on) - I've written one and Mattjis Kneppers has just implemented one.

Jadie Rage's icon

Just wanted to say that I found this helpful when putting together an external UDP connection to Max. Thanks!

What is the scoop on addresses? It seems that when sending to Max, the address just comes through as part of the message (prepended to the list). Is the intent to use this on a [route] object or something?

Floating Point's icon

Hey Vektoren, I'm not able to open those pdfs you posted back in 2011. I've tried in both firefox and safari on a mac-- has anybody been able to open these?

Rick's icon

I was able to save the pdf to the desk top, then open it with Preview.

Floating Point's icon

strange, tried that, doesn't work-- do you mind emailing your pdf to me Rick?

terrymc at pacific dot net dot au

Rick's icon

n.p. sent