aboutsummaryrefslogtreecommitdiffstats
path: root/Bowelyzer.sc
diff options
context:
space:
mode:
Diffstat (limited to 'Bowelyzer.sc')
-rw-r--r--Bowelyzer.sc92
1 files changed, 91 insertions, 1 deletions
diff --git a/Bowelyzer.sc b/Bowelyzer.sc
index 3d01b1a..3071588 100644
--- a/Bowelyzer.sc
+++ b/Bowelyzer.sc
@@ -22,10 +22,100 @@ Bowelyzer{
server.waitForBoot({
hub = BowelyzerOSCHub.new(config.config);
analyzer = BowelyzerAnalyzer.new(config.config);
- //gui = BowelyzerGUI.new(config.config);
+ gui = BowelyzerGUI.new(config.config);
+ this.addGUIListeners;
},
5,
{"scsynth failed to start!".postln});
}
+ addGUIListeners{
+ OSCdef.newMatching(
+ key: \controls,
+ func: {|msg, time, addr, recvPort|
+ postln("Received: "++msg);
+ // if the control exists, change it
+ if(msg[1].notNil && msg[2].notNil && msg[3].notNil,{
+ if(config.config.at(\controls).includesKey(msg[1]),{
+ if(config.config.at(\controls).at(msg[1]).includesKey(msg[2]),{
+ config.config.at(\controls).at(msg[1]).put(msg[2], config.getControlValue(msg[2], msg[3]));
+ });
+ });
+ });
+ },
+ path: "/controls",
+ srcID: NetAddr.new("127.0.0.1", NetAddr.langPort)
+ );
+ OSCdef.newMatching(
+ key: \inputs,
+ func: {|msg, time, addr, recvPort|
+ postln("Received: "++msg);
+ if(msg[1].notNil && msg[2].notNil && msg[3].notNil,{
+ if(config.config.at(\inputs).includesKey(msg[1]) && config.config.at(\controls).includesKey(msg[1]),{
+ switch(msg[2],
+ \name,{
+ //if the name exists and the new name is not empty, change it
+ if(msg[3]!= "",{
+ //move the controls
+ config.config.at(\controls).put(msg[3].asSymbol, config.config.at(\controls).at(msg[1]));
+ config.config.at(\controls).removeAt(msg[1].asSymbol);
+ // rename the input
+ config.config.at(\inputs).put(msg[3].asSymbol, config.config.at(\inputs).at(msg[1]));
+ config.config.at(\inputs).removeAt(msg[1]);
+ // rename the GUI element in channelView
+ Routine{
+ gui.channels.keysValuesDo({|name, channelView|
+ postln(name++"->"++channelView.name);
+ if(channelView.name.asSymbol == msg[1].asSymbol, {
+ channelView.name = msg[3].asSymbol;
+ });
+ });
+ //TODO: rename the LevelListener
+ }.play(AppClock);
+ // free the synth on the server and start a new one according to the config
+ analyzer.freeAnalysisSynth(msg[1].asSymbol);
+ analyzer.addSynthWithName(msg[3]);
+ Routine{
+ 1.wait;
+ analyzer.startSynthWithNameAndControls(msg[3].asSymbol, config.config.at(\controls).at(msg[3]), config.config.at(\inputs).at(msg[3]));
+ }.play;
+ hub.freeSynthListener(msg[1]);
+ hub.addSynthListener(msg[3]);
+ hub.startSynthListener(msg[3]);
+ });
+ },
+ \input,{
+ // if the input name exists and the new is an Integer and greater/equal 0
+ if(((msg[3].isInteger) && (msg[3].asInteger >= 0)),{
+ // change the input in configuration
+ config.config.at(\inputs).put(msg[1], msg[3].asInteger);
+ analyzer.setSynthControl(msg[1].asSymbol, \inputChannel, msg[3].asInteger);
+ });
+ }
+ );
+ });
+ });
+ },
+ path: "/inputs",
+ srcID: NetAddr.new("127.0.0.1", NetAddr.langPort)
+ );
+ OSCdef.newMatching(
+ key: \toggle,
+ func: {|msg, time, addr, recvPort|
+ postln("Received: "++msg);
+ if(msg[1].notNil && msg[2].notNil && msg[3].notNil,{
+ if(config.config.at(\inputs).includesKey(msg[1]),{
+ switch(msg[3],
+ 0,{analyzer.startAnalysisSynth(msg[1])},
+ 1,{analyzer.stopAnalysisSynth(msg[1])}
+ );
+ });
+ });
+ },
+ path: "/toggle",
+ srcID: NetAddr.new("127.0.0.1", NetAddr.langPort)
+ );
+ }
+ //TODO: add SimpleController
+ //TODO: delegate changes to BowelyzerConfig.config and update analyzer and GUI with it
}