aboutsummaryrefslogtreecommitdiffstats
path: root/classes/Bowelyzer.sc
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2016-07-08 20:44:20 +0200
committerDavid Runge <dave@sleepmap.de>2016-07-08 20:44:20 +0200
commit0ead8c750802a7924d8d68a8b20a3ccf93ef6979 (patch)
treee4a30c004ec2395d8719067d30ec44fe93a27c06 /classes/Bowelyzer.sc
parent8641328aa6eba6b24391dca1d7f6516beaea8d04 (diff)
downloadbowelyzer-0ead8c750802a7924d8d68a8b20a3ccf93ef6979.tar.gz
bowelyzer-0ead8c750802a7924d8d68a8b20a3ccf93ef6979.tar.bz2
bowelyzer-0ead8c750802a7924d8d68a8b20a3ccf93ef6979.tar.xz
bowelyzer-0ead8c750802a7924d8d68a8b20a3ccf93ef6979.zip
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.
Diffstat (limited to 'classes/Bowelyzer.sc')
-rw-r--r--classes/Bowelyzer.sc68
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,