| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- s.boot;
- s.reboot;
- (
- // Define a custom function that listens on a given port
- ~startOSCListener = { |port, oscAddress|
- // Create a NetAddr for the server to bind to
- var udpIn, listener;
- // Start listening on the port
- udpIn = NetAddr.langPort(port); // binds to this port
- // Define the listener
- listener = OSCdef.new(
- key: "myOSCListener", // unique identifier
- func: { |msg, time, addr, recvPort|
- var val;
- val = msg[1]; // assuming single float argument
- // Print in the console (just for debugging)
- ["[OSC RECEIVED]", msg, "from", addr].postln;
- // Example: do something with `val`
- // You could control a Synth here
- },
- path: oscAddress,
- srcID: nil, // nil = accept from any IP
- recvPort: port
- );
- "Listening for OSC on port % at address '%'\n".format(port, oscAddress).postln;
- };
- )
- // Start the listener
- ~startOSCListener.(port: 8000, oscAddress: "/touchX"); // Change the oscAddress depending on what you want to receive
|