Receiving OSC in SuperCollider

OSCFunc

By default, a running instance of sclang listens to incoming OSC messsages on the port 57120. For listening to a specific OSC message, an OSC function can be defined with a specific path. SC will then evaluate the defined function when OSC messages are received at the default port with the matching path:

~osc_receive = OSCFunc(

{ arg msg, time, addr, recvPort;

post('Revceived message to path: ');
msg[0].postln;

post('With value: ');
msg[1].postln;

}, '/test/message');

Exercise


OSCdef

OSCdef is more flexible and allows to change definitions on the fly, without deleting nodes (the OSCdef identifier does not have to match the OSC path - but it does in this example):

OSCdef(\poster,

        {|msg, time, addr, recvPort|

        post('With value: ');
        msg[1].postln;

},'/poster', n);

Exercises


Opening Specific UDP Ports

For many applications it can be helpul to open a specific port for a puropse. Sometimes the server booting process can be interrupted by messages being sent to ''57120'' before booting is competed. An additional port can be opened like this:

thisProcess.openUDPPort(6666);

A list of all open ports can be queried from the language:

thisProcess.openPorts