home/ atoms/ osc-message-routing-max

In Max the [route] object both separates OSC messages by address pattern and strips that pattern off, dispatching each to its handler

When multiple OSC messages arrive on a single port in Max, they must be de-multiplexed before use: messages with different address patterns need to reach different parameters, and each message’s address must be stripped from its arguments. The [route] object does both of these tasks — it inspects the leading address pattern, sends matching messages out a dedicated outlet, and passes on only the remaining arguments. This is the standard receive-and-dispatch step for OSC in Max. Once dispatched, list-style arguments (e.g. an accelerometer’s X/Y/Z as a three-element list) can be broken into individual number streams with the [unpack] object for downstream mapping.

Examples

OSC message ‘/accel 0.12 -0.05 0.98’ arrives at [udpreceive 9000]. [route /accel] passes ‘0.12 -0.05 0.98’ to its outlet, prefix stripped. [unpack f f f] then separates the three floats for X, Y, and Z processing.

Assessment

Describe the Max patch structure needed to receive two OSC address patterns — ‘/gyro’ and ‘/accel’ — each carrying three float arguments, and route each axis to a separate number box.

“We first need to separate messages with different address patterns so messages go to the correct parameter and secondly we need to separate the address patterns from the arguments themselves. The \[route\] object luckily does both of these tasks.”
corpus · introduction-to-open-sound-control-osc-mct-blog · chunk 1