diff options
-rw-r--r-- | BowelyzerAnalyzer.sc | 4 | ||||
-rw-r--r-- | 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 <controlsWithSlider = #[ + \amplitudeAttackTime, + \amplitudeReleaseTime, + \hfHainsworth, + \hfFoote, + \hfThreshold, + \hfWaitTime, + \pitchInitFreq, + \pitchMinFreq, + \pitchMaxFreq, + \pitchExecFreq, + \pitchMaxBinsPerOctave, + \pitchMedian, + \pitchAmpThreshold, + \pitchPeakThreshold, + \pitchDownSample, + \sendReplyFreq + ]; + const <controlsWithRanger = #[ \test]; + const <controlsWithKnob = #[ \test]; + var <config, <defaultConfig, <defaultControls, @@ -10,6 +31,18 @@ BowelyzerConfig{ <hasToBeDictionary, <hasToBeFloat; + *controlContainedIn{ + arg control; + if(BowelyzerConfig.controlsWithSlider.asString.contains(control.asString),{ + ^\slider; + }); + if(BowelyzerConfig.controlsWithRanger.asString.contains(control.asString),{ + ^\ranger; + }); + if(BowelyzerConfig.controlsWithKnob.asString.contains(control.asString),{ + ^\knob; + }); + } *new{ arg config; @@ -18,6 +51,7 @@ BowelyzerConfig{ init{ arg configFile; + //TODO: Use ControlSpec to setup standard values/boundaries hasToBeString = [ \forwardAddress, \hubAddress, @@ -31,10 +65,10 @@ BowelyzerConfig{ \pitchDownSample ]; hasToBeArray = [ - \names, - \channelOffset + \names ]; hasToBeDictionary = [ + \inputs, \controls, \left, \right @@ -85,7 +119,10 @@ BowelyzerConfig{ "sendReplyFreq" ->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) |