From 0ead8c750802a7924d8d68a8b20a3ccf93ef6979 Mon Sep 17 00:00:00 2001 From: David Runge Date: Fri, 8 Jul 2016 20:44:20 +0200 Subject: classes/Bowelyzer.sc: Adding /free OSC listener, to be able to close channels. Moving the update functionality for LevelIndicators to BowelyzerGUI.sc. Naming OSCdefs properly using Symbols. classes/BowelyzerGUI.sc: Adding close Button for each channel. Adding free function for the OSC indicator fadeout Tasks. Naming more objects, if possible. --- classes/Bowelyzer.sc | 68 ++++++++++++++++++++++++------------ classes/BowelyzerGUI.sc | 93 +++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 127 insertions(+), 34 deletions(-) (limited to 'classes') 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, diff --git a/classes/BowelyzerGUI.sc b/classes/BowelyzerGUI.sc index 675e100..ad4507c 100644 --- a/classes/BowelyzerGUI.sc +++ b/classes/BowelyzerGUI.sc @@ -8,8 +8,8 @@ BowelyzerGUI{ fadeOutSteps = 20, minWidth=1280, minHeight=720, - channelViewHeight = 700, - channelViewWidth = 300, +