I am trying to receive string from python into MAX/MSP receiving use udpreceive

Mohamed Debashi's icon

I tried many strings such as message = 'AA' or tried '11' or 'BBB' I always receive error : udpreceive . OSC packet size (2) not a multiple of 4 bytes: dropping or I get : udpreceive . OSC Bad message name string: DataAfterAlignedString: Unreasonably long string dropping entire message

hz37's icon

You're being kinda terse. What OS? Which Max version? Which python? Which osc lib? What did you try? Where's your patch? It really helps to specify such things. Anyways, that said, I have no problem sending strings from python3 using python-osc on my Macbook Pro to Max 7. I have installed python-osc via pip:

pip3 install python-osc

The python sending code can be as simple as:

from pythonosc import osc_message_builder
from pythonosc import udp_client

client = udp_client.UDPClient('127.0.0.1', 8000)

msg = osc_message_builder.OscMessageBuilder(address = '/hey')
msg.add_arg('something special')
msg = msg.build()
client.send(msg)

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

Then, in Max, it's a mere matter of instantiating an [udpreceive] object with the proper port. You can use whatever pleases you to parse the incoming data.

Good luck!

midinerd's icon

Thanks for this ^