From 5b3f3167eaf5f4165ba471afc7b3894e1d81ce79 Mon Sep 17 00:00:00 2001 From: David Runge Date: Mon, 13 Jun 2016 00:02:17 +0200 Subject: BowelyzerConfig.sc: Adding class constants to check what sort of GUI element the different parameter require. Removing the channel offset feature in favor of addressing inputs directly (starting from 0). BowelyzerAnalyzer.sc: Removing the channel offest feature. --- BowelyzerAnalyzer.sc | 4 +-- BowelyzerConfig.sc | 72 ++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 61 insertions(+), 15 deletions(-) diff --git a/BowelyzerAnalyzer.sc b/BowelyzerAnalyzer.sc index 055a3b4..928bef2 100644 --- a/BowelyzerAnalyzer.sc +++ b/BowelyzerAnalyzer.sc @@ -33,7 +33,7 @@ BowelyzerAnalyzer{ arg config; config.at("names").size.do({|i| var name = config.at("names")[i]; - ("Adding SynthDef '"++name++"' on input "++(i+config.at("channelOffset")[i])).postln; + ("Adding SynthDef '"++name++"' on input "++i).postln; SynthDef(name, { arg sendReplyFreq, amplitudeAttackTime, @@ -54,7 +54,7 @@ BowelyzerAnalyzer{ ; var amplitude, input, detect, pitch, hasPitch; //TODO: Add volume for SoundIn - input = SoundIn.ar(bus: i+config.at("channelOffset")[i]); + input = SoundIn.ar(bus: i); amplitude = Amplitude.kr( in: input, attackTime: amplitudeAttackTime, diff --git a/BowelyzerConfig.sc b/BowelyzerConfig.sc index 6f35500..4079119 100644 --- a/BowelyzerConfig.sc +++ b/BowelyzerConfig.sc @@ -1,5 +1,26 @@ BowelyzerConfig{ + const 20 ]); defaultConfig = Dictionary.with(*[ - "channelOffset" -> [0, 0], + "inputs" -> Dictionary.with(*[ + "left" -> 0, + "right" -> 1 + ]), "names" -> ["left", "right"], "synthServerAddress" -> "127.0.0.1", "synthServerPort"->57110, @@ -158,11 +195,6 @@ BowelyzerConfig{ broken = true; },{ //setting correct types in Arrays - if((key == "channelOffset") && (value.size >= 1) && value[0].isKindOf(Integer).not,{ - for(0, value.size-1, {|i| - config.at(key)[i] = value[i].asInteger; - }); - }); if((key == "names") && (value.size >= 1) && value[0].isKindOf(String).not,{ for(0, value.size-1, {|i| config.at(key)[i] = value[i].asString; @@ -190,17 +222,31 @@ BowelyzerConfig{ }); }); }); + //check if inputs dictionaries are set up correctly + if(key == "inputs", { + value.keysValuesDo({|name, input| + if(input.isKindOf(Integer).not, { + error("Value ("++input++") of key ("++name++") should be of type Integer."); + config.at("inputs").put(name -> input.asInteger); + }); + }); + }); }); // if not completely broken, fix stuff if(broken,{ - error("There were errors. Reverting to default config."); + error("There were serious errors. Reverting to default config."); config = this.createDefaultConfig; },{ postln("Fixing stuff"); - // zero-pad channel offsets - if(config.at("names").size > config.at("channelOffset").size,{ - var difference = config.at("names").size - config.at("channelOffset").size; - config.at("channelOffset").asArray = config.at("channelOffset")++Array.fill(difference, {arg i; i*0}); + // disable and zero-pad channels without inputs + if(config.at("names").size > config.at("inputs").size,{ + error("More channels than inputs defined. Disabling missing."); + config.at("names").do({|name,i| + if(config.at("inputs").includesKey(name).not,{ + config.at("inputs").put(name.asString -> 0); + //TODO: Disable here. + }); + }); }); //TODO: add defaultControls for channels that have none //TODO: fill non-existing keys with default values (in case config file is incomplete) -- cgit v1.2.3-54-g00ecf