aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2016-06-13 00:02:17 +0200
committerDavid Runge <dave@sleepmap.de>2016-06-13 00:02:17 +0200
commit5b3f3167eaf5f4165ba471afc7b3894e1d81ce79 (patch)
treeb3e4afa9ec8194655d10679636d4c5ac41570dd5
parentcd08e85995e3f42b5829a5aa3cbdbffcae40deb0 (diff)
downloadbowelyzer-5b3f3167eaf5f4165ba471afc7b3894e1d81ce79.tar.gz
bowelyzer-5b3f3167eaf5f4165ba471afc7b3894e1d81ce79.tar.bz2
bowelyzer-5b3f3167eaf5f4165ba471afc7b3894e1d81ce79.tar.xz
bowelyzer-5b3f3167eaf5f4165ba471afc7b3894e1d81ce79.zip
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.
-rw-r--r--BowelyzerAnalyzer.sc4
-rw-r--r--BowelyzerConfig.sc72
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)