From 8c1385e53c8c422b94e9f53a4c555e906a2564f2 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sat, 9 Jul 2016 06:22:30 +0200 Subject: classes/BowelyzerConfig.sc: Adding functions to add a single input channel with unique identifier (name). Updating comments and TODOs. --- classes/BowelyzerConfig.sc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/BowelyzerConfig.sc b/classes/BowelyzerConfig.sc index 1a4ce87..b521203 100644 --- a/classes/BowelyzerConfig.sc +++ b/classes/BowelyzerConfig.sc @@ -170,7 +170,7 @@ BowelyzerConfig{ ]); } -// read configuration from file + // read configuration from file readConfigurationFile{ arg configFile; var configFromFile, reader, path; @@ -233,6 +233,7 @@ BowelyzerConfig{ }); } + //TODO: use order to sort the controls and inputs by name // write a valid JSON file from configuration writeConfigurationFile{ arg fileName; @@ -411,6 +412,27 @@ BowelyzerConfig{ ^true; } + // add an input with standard controls to the config + addInput{ + var name = this.createUniqueIdentifier; + config.at(\inputs).put(name, 0); + this.validateConfig; + ^name; + } + + // create a unique identifier of the form msg[number] + createUniqueIdentifier{ + var msg = \msg1, + iterator = 0; + while({ + config.at(\inputs).includesKey(msg) + },{ + iterator = (msg.asString.replace("msg", "").asInteger) + 1; + msg = ("msg"++iterator).asSymbol; + }); + ^msg.asSymbol; + } + //print the current config showConfig{ postln("Configuration is: "); -- cgit v1.2.3-70-g09d2