0

I'm currently trying to figure out how to send OSC messages from Python to Max/MSP. I'm currently using osc4py3 to do so, and I have a sample code from the documentation that should hypothetically be working, written out here:

from osc4py3.as_eventloop import *
from osc4py3 import oscbuildparse

# Start the system.
osc_startup()

# Make client channels to send packets.
osc_udp_client("127.0. 0.1", 5000, "tester")

msg = oscbuildparse.OSCMessage("/test/me", ",sif", ["text", 672, 8.871])
osc_send(msg, "tester")

The receiver in Max is just a udprecieve object listening to port 5000. I managed to get Processing to send OSC messages to Max and it worked pretty simply using the oscp5 library, but I can't seem to have the same luck in Python.

What is it I'm missing? Moreover, I don't entirely understand the structure for building OSC messages in osc4py3, even after doing my best with the documentation; if someone would be willing to explain what exactly is going on (namely, the arguments) in something like

msg = oscbuildparse.OSCMessage("/test/me", ",sif", ["text", 672, 8.871])

then I would be forever grateful.

I'm entirely open to using another OSC library, but all I ask is a run-through on how to send a message (I've attempted using pyOSC but that too proved too confusing for me).

JohnH
  • 2,713
  • 12
  • 21

2 Answers2

0

Maybe you already solved it but in the posted code there are two problems. One is the IP address format (there is a space before the second "0"). Then you need the command osc.process() at the end. So the following way should work

from osc4py3.as_eventloop import *
from osc4py3 import oscbuildparse

# Start the system.
osc_startup()

# Make client channels to send packets.
osc_udp_client("127.0.0.1", 5000, "tester")

msg = oscbuildparse.OSCMessage("/test/me", ",sif", ["text", 672, 
8.871])
osc_send(msg, "tester")
osc_process()

Hope it will work out

0

There are different possible scheduling policies in osc4py3. The documentation uses the event-loop model with as_eventloop, where user code must periodically call osc_process() to have osc4py3 deal with internal messages queues and communications.

The client example for sending OSC messages wrap osc_process() call in a loop (generally it is into an event processing loop).

You may dismiss osc_process() call simply by importing names with full multithreading scheduling policy at the beginning of your code:

from osc4py3.as_allthreads import *

The third scheduling policy is as_comthreads, where communications are processed in background threads, but received messages (in server side) are processed synchronously at the osc_process() call.

(by the author of osc4py3)