From fe06ccfb8d92caa775dcb029c67d887d28066141 Mon Sep 17 00:00:00 2001 From: David Runge Date: Wed, 22 Jun 2016 02:04:19 +0200 Subject: BowelyzerOSCHub.sc: Renaming adding function for Synth listener. Creating start/stop/free functions for the OSCdefs. Moving the adding of a single Synth listener to a separate function, to be able to call it separately. --- BowelyzerOSCHub.sc | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/BowelyzerOSCHub.sc b/BowelyzerOSCHub.sc index 4a7db26..7de5b72 100644 --- a/BowelyzerOSCHub.sc +++ b/BowelyzerOSCHub.sc @@ -15,7 +15,7 @@ BowelyzerOSCHub{ init{ arg config; this.setupNetAddressesFromConfig(config); - this.setupSynthListener(config); + this.setupSynthListenersFromConfig(config); } setupNetAddressesFromConfig{ @@ -25,23 +25,42 @@ BowelyzerOSCHub{ synthServer = BowelyzerOSCHub.getNetAddr(config.at(\synthServerAddress), config.at(\synthServerPort)); } -// setup OSCdef for SynthServerAddress:SynthServerPort - setupSynthListener{ + // setup OSCdef for SynthServerAddress:SynthServerPort + setupSynthListenersFromConfig{ arg config; // listen for individual SendReply messages config.at(\inputs).keysValuesDo({|name, input| postln("Listening for messages called '/"++name++"' coming from scsynth at "++synthServer.ip++":"++synthServer.port++"."); - OSCdef.newMatching( - name, - {|msg, time, addr, recvPort| this.forwardToNetAddress(msg, time)}, - name, - synthServer, - hub.port - ); - OSCdef(name).enable; + this.addSynthListener(name); }); } + addSynthListener{ + arg name; + OSCdef.newMatching( + name, + {|msg, time, addr, recvPort| this.forwardToNetAddress(msg, time)}, + name, + synthServer, + hub.port + ); + } + + startSynthListener{ + arg name; + OSCdef(name).enable; + } + + stopSynthListener{ + arg name; + OSCdef(name.asSymbol).disable; + } + + freeSynthListener{ + arg name; + OSCdef(name.asSymbol).free; + } + //forward a received OSC message to the globally specified forward address forwardToNetAddress{ arg msg, time; -- cgit v1.2.3-70-g09d2