Skip to content

Instantly share code, notes, and snippets.

@iani
Last active December 31, 2018 04:44
Show Gist options
  • Select an option

  • Save iani/f5c4102a84866d43f639075f8e609df1 to your computer and use it in GitHub Desktop.

Select an option

Save iani/f5c4102a84866d43f639075f8e609df1 to your computer and use it in GitHub Desktop.
forwarding osc messages (for nymphs telematic dance project). Needs sc-hacks
// 30 Dec 2018 22:05 with Nikos Charalambidis
// Ekaterini <-> Tokyo
//:add oscfunc for forwarding.
//Use Registry to keep the trace function:
Registry(\forwardfunc, {
var forwardAddr, hosts;
// you can add more hosts here!
// var forwardAddr2; // example of one more host
forwardAddr = NetAddr("25.80.47.40", 57120);
hosts = [forwardAddr /*, forwardAddr2 */];
// then you need to send to all of them using hosts.do{ .... }
{ | msg, time, addr |
// only forward data received from sensors via port 12345:
if (addr.port == 12345) {
hosts do: { | host |
host.sendMsg(*msg);
};
}
}
});
//:Now add the function to activate it
// this will run whenever OSC is received.
thisProcess.addOSCRecvFunc(
Registry.at(\forwardfunc)
);
//:How to change the osc func
// Note To replace the above func with something else,
// You need to do 4 things:
// 1. Remove the old func from thisProcess
// 2. Remove the old func from Registry
// 3. Store the new func in registry
// 4. Add the new func from registry to thisProcess
// Here are the first 2 steps from above:
// Remove forward funct to replace it if needed
/* if you want to change the above function, then
you need to remove it both from the OSCRecvFunc and
from the registry before repeating the process
to add a new function; */
thisProcess.addOSCRecvFunc(Registry.at(\forwardfunc));
Registry.at(\forwardfunc).objectClosed;
//:
NetAddr.localAddr.port;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment