UDP from Max/MSP to Processing

Jun 19, 2013 at 3:50am

UDP from Max/MSP to Processing

I’m trying to send MIDI from Max/MSP to Processing via udp. I have a number box with 0-127 values connected to udpsend. It is on the same port as the Processing patch, which uses the UDP library (http://ubaa.net/shared/processing/udp/)

The problem is, at the Processing end I get this:
receive: “int,i” from 127.0.0.1 on port 57041

I have no idea how to get an actual number value from this. It seems like it is receiving as ‘i’ instead of an actual number, or am I missing something fundamental? Trying to establish if this is a problem at the max end or at the Processing end.

Bang messages are received like this:
receive: “bang,” from 127.0.0.1 on port 57041

Should integer messages not be received as “int,63″ (etc.) ?

Any help appreciated!

#253232
Jun 19, 2013 at 6:33am

In Processing I’m using the library ‘oscP5′ to receive data from Max via UDP without any problems.

#253253
Jun 19, 2013 at 6:40am

I tried it with oscP5 but I must be missing something with regards to receiving the messages… do you have to do anything other than send numbers to the udpsend object? How do you unparse the information in Processing?

#253254
Jun 19, 2013 at 6:59am

Hi, the reason is that udpsend is sending data in OSC format over UDP. If you just want to send integers in the range 0-127, you might be interested in the [sadam.udpSender] from The sadam Library (see http://cycling74.com/forums/topic/announce-the-sadam-library-version-2012-10-08 ). I’d also recommend doing a forum search, as there are quite similar topics, eg:

http://cycling74.com/forums/topic/midi-via-udp-max-data-types

http://cycling74.com/forums/topic/best-way-to-receive-udp-data-form-sensors

http://cycling74.com/forums/topic/udposc-message-serialization-format

etc.

HTH,
Ádám

#253260
Jun 19, 2013 at 7:02am

In Max you can simply send numbers to the udpsend object (but in general the OSC format requires a prepended address like “/mynumber”).

With oscP5 the receiver in Processing would be something like this

void oscEvent(OscMessage theOscMessage) {
println(“addr: “+theOscMessage.addrPattern());
println(“type: “+theOscMessage.typetag());
println(“args: “+theOscMessage.get(0).intValue());
}

See also example ‘oscP5sendReceive’ from the library.

#253261
Jun 19, 2013 at 7:25am

Thanks, got it working now. I was missing the bits for getting the argument at the Processing end:

theOscMessage.get(0).intValue();

Also the stuff about prepending in Max is useful to know. In the meantime I figured out getting MIDI directly into Processing so now I have both options. :-)

#253264

You must be logged in to reply to this topic.