From 7e89ddf046689e5691e0479ad3690c04315c2407 Mon Sep 17 00:00:00 2001 From: David Runge Date: Thu, 30 Jun 2016 13:00:59 +0200 Subject: Bowelyzer.sc: Simplifying calls to setupLevelListener. Adding comments. Adding config write upon using toggle functionality. --- Bowelyzer.sc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Bowelyzer.sc b/Bowelyzer.sc index 84ba4da..85a6edc 100644 --- a/Bowelyzer.sc +++ b/Bowelyzer.sc @@ -82,16 +82,17 @@ Bowelyzer{ }.play(AppClock); // stop the listener for LevelIndicator by name and start a new one based upon the updated name OSCdef(\levels_++name).free; - this.setupLevelListener(update, NetAddr.new(config.config.at(\synthServerAddress), config.config.at(\synthServerPort))); + this.setupLevelListener(update, hub.synthServer); // free the synth on the server and start a new one according to the config analyzer.freeAnalysisSynth(name.asSymbol); analyzer.synths.removeAt(name); analyzer.addSynthWithName(update); - //TODO: only start the Synth, if the channel toggle button is okay + // start the Synth (possibly paused) Routine{ 1.wait; analyzer.startSynthWithNameAndControls(update.asSymbol, config.config.at(\controls).at(update), config.config.at(\inputs).at(update)); }.play; + // rename the hub listener for the Synth hub.freeSynthListener(name); hub.addSynthListener(update); hub.startSynthListener(update); @@ -117,11 +118,17 @@ Bowelyzer{ var name = msg[1], toggle = msg[2]; postln("Received: "++msg); - if(msg[1].notNil && msg[2].notNil && msg[2].isInteger,{ + if(name.notNil && toggle.notNil && toggle.isInteger,{ if(config.config.at(\inputs).includesKey(name),{ switch(toggle, - 0,{analyzer.startAnalysisSynth(name)}, - 1,{analyzer.stopAnalysisSynth(name)} + 0,{ + config.config.at(\controls).at(name).put(\active, true); + analyzer.startAnalysisSynth(name); + }, + 1,{ + config.config.at(\controls).at(name).put(\active, false); + analyzer.stopAnalysisSynth(name); + } ); }); }); @@ -136,7 +143,7 @@ Bowelyzer{ this.setupIndicatorListener; // add and start a listener for each channel's LevelIndicator config.config.at(\inputs).pairsDo({|key,value| - this.setupLevelListener(key, NetAddr.new(config.config.at(\synthServerAddress), config.config.at(\synthServerPort))); + this.setupLevelListener(key, hub.synthServer); }); } -- cgit v1.2.3-70-g09d2