From 0f3042be76212505404e1860011e529b803b0e52 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sat, 9 Jul 2016 06:29:09 +0200 Subject: classes/Bowelyzer.sc: Adding OSCdef for adding new channel. Including the add channel Button width to width for resizing of channelContainerView on channel deletion. --- classes/Bowelyzer.sc | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Bowelyzer.sc b/classes/Bowelyzer.sc index 2ff0e75..ba5eeb8 100644 --- a/classes/Bowelyzer.sc +++ b/classes/Bowelyzer.sc @@ -243,13 +243,44 @@ Bowelyzer{ }); }); // resize the channelContainerView according to new amount of channels - gui.channelContainerView.maxSize_((gui.channelViewWidth*config.config.at(\inputs).size)@gui.channelViewHeight); + gui.channelContainerView.maxSize_(((gui.channelViewWidth*config.config.at(\inputs).size)+gui.buttonWidth)@gui.channelViewHeight); }.defer; }, path: "/free", srcID: NetAddr.new("127.0.0.1", NetAddr.langPort) ); + // listen for messages to add channels + OSCdef.newMatching( + key: \add, + func: {|msg, time, addr, recvPort| + var type = msg[0], + name; + postln("Received: "++msg); + // add a new input to the config + name = config.addInput; + // initialize a new channelView with the name and controls + Routine{ + // resize the container View + gui.channelContainerView.maxSize_(((gui.channelViewWidth*config.config.at(\inputs).size)+gui.buttonWidth)@gui.channelViewHeight); + gui.channelContainerView.asView.bounds_(Rect(0, 0, (gui.channelViewWidth*config.config.at(\inputs).size)+gui.buttonWidth, gui.channelViewHeight)); + // add a new channel View for the controls + gui.setupChannelView(name, config.config); + }.play(AppClock); + // add and start a new Synth by the given name + Routine{ + analyzer.addSynthWithName(name); + 1.wait; + analyzer.startSynthWithNameAndControls(name, config.config.at(\controls).at(name), config.config.at(\inputs).at(name)); + }.play; + // setup a LevelListener for the new Synth + this.setupLevelListener(name, hub.synthServer); + // setup a OSC listener for the Synth by name + hub.addSynthListener(name); + }, + path: "/add", + srcID: NetAddr.new("127.0.0.1", NetAddr.langPort) + ); } // add OSCdefs listening for messages coming from scsynth, to update the GUI @@ -268,7 +299,7 @@ Bowelyzer{ key: \indicate, func: {|msg, time, addr, recvPort| var name = msg[1]; - //postln("Indicate for "++name); +// postln("Indicate for "++name); if(config.config.at(\inputs).includesKey(name),{ if(gui.indicators.includesKey(name),{ gui.indicators.at(name).stop; -- cgit v1.2.3-70-g09d2