From 393dde90a4b7f3cdabf8b704057c0f8ea2982ca0 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sun, 10 Jul 2016 19:21:31 +0200 Subject: classes/Bowelyzer.sc: Adding support for rename prevention, if the name is already used or empty. Adding TODOs for refactoring of functionalities. --- classes/Bowelyzer.sc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'classes') diff --git a/classes/Bowelyzer.sc b/classes/Bowelyzer.sc index 3a61618..a877a89 100644 --- a/classes/Bowelyzer.sc +++ b/classes/Bowelyzer.sc @@ -62,15 +62,15 @@ Bowelyzer{ if(config.config.at(\inputs).includesKey(name) && config.config.at(\controls).includesKey(name),{ switch(type, \name,{ - //if the name exists and the new name is not empty, change it - //FIXME: check whether new name exists and only setup then, else reset the textfield - if(update != "",{ + // if the name is not empty and not used, change to it + if((update != "") && config.config.at(\inputs).includesKey(update).not, { //move the controls config.config.at(\controls).put(update.asSymbol, config.config.at(\controls).at(name)); config.config.at(\controls).removeAt(name.asSymbol); // rename the input config.config.at(\inputs).put(update.asSymbol, config.config.at(\inputs).at(name)); config.config.at(\inputs).removeAt(name); + //TODO: refactor into gui function Routine{ // rename the channel View gui.channels.do({|channel| @@ -86,19 +86,25 @@ Bowelyzer{ // stop the listener for LevelIndicator by name and start a new one based upon the updated name OSCdef(("levels_"++name).asSymbol).free; this.setupLevelListener(update, hub.synthServer); + //TODO: refactor into function // free the synth on the server and start a new one according to the config analyzer.freeAnalysisSynth(name.asSymbol); analyzer.synths.removeAt(name); + //TODO: refactor into function analyzer.addSynthWithName(update); // 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; + //TODO: refactor into function // rename the hub listener for the Synth hub.freeSynthListener(name); hub.addSynthListener(update); hub.startSynthListener(update); + },{ + ("New name not valid: "++update).error; + gui.setChannelName(name, name); }); }, \input,{ -- cgit v1.2.3-70-g09d2