From 830f1d296e402a89c6146e4183e1a2490ca64406 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sun, 19 Jun 2016 19:33:36 +0200 Subject: Bowelyzer.sc, BowelyzerAnalyzer.sc, BowelyzerConfig.sc, BowelyzerOSCHub.sc: Moving from String based identifiers to Symbols. Further refining the configuration parsing and validation process. darmstadt.json: Moving names into inputs Dictionary, holding channel number (offsets are not required/feasible) and name. --- BowelyzerAnalyzer.sc | 52 +++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'BowelyzerAnalyzer.sc') diff --git a/BowelyzerAnalyzer.sc b/BowelyzerAnalyzer.sc index 928bef2..f50f89d 100644 --- a/BowelyzerAnalyzer.sc +++ b/BowelyzerAnalyzer.sc @@ -11,9 +11,9 @@ BowelyzerAnalyzer{ init{ arg config; - synths = Dictionary.new(config.at("names").size); + synths = Dictionary.new(config.at(\inputs).size); this.setupGroups; - this.addAnalysisSynthsFromConfig(config); + this.addSynthsFromConfig(config); Routine{ 1.wait; this.startSynthsFromConfig(config); @@ -29,11 +29,10 @@ BowelyzerAnalyzer{ } // add synths for the defined channels - addAnalysisSynthsFromConfig{ + addSynthsFromConfig{ arg config; - config.at("names").size.do({|i| - var name = config.at("names")[i]; - ("Adding SynthDef '"++name++"' on input "++i).postln; + config.at(\inputs).keysValuesDo({|name, inputChannel| + ("Adding SynthDef \""++name++"\" on input "++inputChannel).postln; SynthDef(name, { arg sendReplyFreq, amplitudeAttackTime, @@ -54,7 +53,7 @@ BowelyzerAnalyzer{ ; var amplitude, input, detect, pitch, hasPitch; //TODO: Add volume for SoundIn - input = SoundIn.ar(bus: i); + input = SoundIn.ar(bus: inputChannel); amplitude = Amplitude.kr( in: input, attackTime: amplitudeAttackTime, @@ -83,7 +82,7 @@ BowelyzerAnalyzer{ ); SendReply.kr( Impulse.kr(sendReplyFreq), - '/'++config.at("names")[i].asSymbol, + "/"++name, [amplitude, pitch, hasPitch, detect] ); }).add; @@ -92,28 +91,27 @@ BowelyzerAnalyzer{ startSynthsFromConfig{ arg config; - config.at("names").do({|name, i| - var controls = config.at("controls").at(name); - postln("Synths: "++name++" at "++i); + config.at(\controls).keysValuesDo({|name, controls| + postln("Starting synth \""++name++"\"."); synths.add(name -> Synth( name, [ - sendReplyFreq: controls.at("sendReplyFreq"), - amplitudeAttackTime: controls.at("amplitudeAttackTime"), - amplitudeReleaseTime: controls.at("amplitudeReleaseTime"), - hfHainsworth: controls.at("hfhainsworth"), - hfFoote: controls.at("hfFoote"), - hfThreshold: controls.at("hfThreshold"), - hfWaitTime: controls.at("hfWaitTime"), - pitchInitFreq: controls.at("pitchInitFreq"), - pitchMinFreq: controls.at("pitchMinFreq"), - pitchMaxFreq: controls.at("pitchMaxFreq"), - pitchExecFreq: controls.at("pitchExecFreq"), - pitchMaxBinsPerOctave: controls.at("pitchMaxBinsPerOctave"), - pitchMedian: controls.at("pitchMedian"), - pitchAmpThreshold: controls.at("pitchAmpThreshold"), - pitchPeakThreshold: controls.at("pitchPeakThreshold"), - pitchDownSample: controls.at("pitchDownSample") + sendReplyFreq: controls.at(\sendReplyFreq), + amplitudeAttackTime: controls.at(\amplitudeAttackTime), + amplitudeReleaseTime: controls.at(\amplitudeReleaseTime), + hfHainsworth: controls.at(\hfhainsworth), + hfFoote: controls.at(\hfFoote), + hfThreshold: controls.at(\hfThreshold), + hfWaitTime: controls.at(\hfWaitTime), + pitchInitFreq: controls.at(\pitchInitFreq), + pitchMinFreq: controls.at(\pitchMinFreq), + pitchMaxFreq: controls.at(\pitchMaxFreq), + pitchExecFreq: controls.at(\pitchExecFreq), + pitchMaxBinsPerOctave: controls.at(\pitchMaxBinsPerOctave), + pitchMedian: controls.at(\pitchMedian), + pitchAmpThreshold: controls.at(\pitchAmpThreshold), + pitchPeakThreshold: controls.at(\pitchPeakThreshold), + pitchDownSample: controls.at(\pitchDownSample) ], analyzerGroup ); -- cgit v1.2.3-70-g09d2