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!
In Processing I'm using the library 'oscP5' to receive data from Max via UDP without any problems.
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?
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 https://cycling74.com/forums/announce-the-sadam-library-version-2012-10-08 ). I'd also recommend doing a forum search, as there are quite similar topics, eg:
https://cycling74.com/forums/midi-via-udp-max-data-types
https://cycling74.com/forums/best-way-to-receive-udp-data-form-sensors
https://cycling74.com/forums/udposc-message-serialization-format
etc.
HTH,
Ádám
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.
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. :-)