diff options
Diffstat (limited to 'classes/Bowelyzer.sc')
-rw-r--r-- | classes/Bowelyzer.sc | 68 |
1 files changed, 45 insertions, 23 deletions
diff --git a/classes/Bowelyzer.sc b/classes/Bowelyzer.sc index 4c4f079..2ff0e75 100644 --- a/classes/Bowelyzer.sc +++ b/classes/Bowelyzer.sc @@ -82,7 +82,7 @@ Bowelyzer{ gui.addOSCIndicatorFadeOutTask(update); }.play(AppClock); // stop the listener for LevelIndicator by name and start a new one based upon the updated name - OSCdef(\levels_++name).free; + OSCdef(("levels_"++name).asSymbol).free; this.setupLevelListener(update, hub.synthServer); // free the synth on the server and start a new one according to the config analyzer.freeAnalysisSynth(name.asSymbol); @@ -202,13 +202,54 @@ Bowelyzer{ var name = msg[0], fileName = msg[1]; postln("Received: "++msg); - config.writeConfigurationFile(fileName); //TODO: destroy current GUI elements //TODO: load channels, etc. }, path: "/load", srcID: hub.local ); + + // listen for messages to free (close) channels + OSCdef.newMatching( + key: \free, + func: {|msg, time, addr, recvPort| + var type = msg[0], + name = msg[1]; + postln("Received: "++msg); + // remove OSCdefs for the channel + OSCdef.all.pairsDo({|key, value| + if(key == name.asSymbol,{ + ("Freeing OSCdef: "++name).postln; + value.free; + }); + if(key == ("levels_"++name).asSymbol,{ + ("Freeing OSCdef: levels_"++name).postln; + value.free; + }); + }); + // free Synth + analyzer.freeAnalysisSynth(name); + // remove configurations for the channel + config.config.at(\inputs).removeAt(name); + config.config.at(\controls).removeAt(name); + // remove fadeout task for OSC indicator + gui.freeOSCIndicatorFadeOutTask(name); + // remove GUI elements + { + gui.channels.do({|channel,i| + if(channel.name == name.asString, { + channel.remove; + gui.channels.remove(channel); + }); + }); + // resize the channelContainerView according to new amount of channels + gui.channelContainerView.maxSize_((gui.channelViewWidth*config.config.at(\inputs).size)@gui.channelViewHeight); + }.defer; + }, + path: "/free", + srcID: NetAddr.new("127.0.0.1", NetAddr.langPort) + ); + } // add OSCdefs listening for messages coming from scsynth, to update the GUI @@ -246,32 +287,13 @@ Bowelyzer{ arg name, server; postln("Setting up LevelListener for: "++name); OSCdef.newMatching( - key: \levels_++name, + key: ("levels_"++name).asSymbol, func: {|msg, time, addr, recvPort| var name = msg[0].asString.replace("/levels/", "").asSymbol, value = msg[3].ampdb.linlin(-40, 0, 0, 1), peak = msg[4].ampdb.linlin(-40, 0, 0, 1); - //postln("Receiving: "++msg); { - gui.channels.do({|channel| - if(channel.name.asSymbol == name,{ - channel.children.do({|channelChild| - if(channelChild.name.asSymbol == \meterAndControls,{ - channelChild.children.do({|meterAndControls| - if(meterAndControls.name.asSymbol == \meterView, { - meterAndControls.children.do({|meterView| - if(meterView.isKindOf(LevelIndicator), { - //postln("Setting up LevelIndicator for "++name); - meterView.value = value; - meterView.peakLevel = peak; - }); - }); - }); - }); - }); - }); - }); - }); + gui.setLevel(name, value, peak); }.defer; }, path: "/levels/"++name, |