From 32f7a4f35d3b63ef9f12f396cd7fb7f9dc18a351 Mon Sep 17 00:00:00 2001 From: David Runge Date: Thu, 14 Jul 2016 13:07:07 +0200 Subject: classes/Bowelyzer.sc: Adding OSCdef for toggle_all message to toggle all channels on/off simultaneously. Reset global toggle state to true on loading of configuration. --- classes/Bowelyzer.sc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'classes') diff --git a/classes/Bowelyzer.sc b/classes/Bowelyzer.sc index 35aa0c3..cea4c55 100644 --- a/classes/Bowelyzer.sc +++ b/classes/Bowelyzer.sc @@ -140,6 +140,34 @@ Bowelyzer{ srcID: NetAddr.new("127.0.0.1", NetAddr.langPort) ); + // listen for messages to toggle all channels on/off simultaneously + OSCdef.newMatching( + key: \toggle_all, + func: {|msg, time, addr, recvPort| + var type = msg[0], + toggle = msg[1]; + postln("Received: "++msg); + switch(toggle, + 0,{ + config.config.at(\controls).pairsDo({|name, controls| + controls.put(\active, true); + analyzer.startAnalysisSynth(name); + gui.setCurrentToggleState(name, true); + }); + }, + 1,{ + config.config.at(\controls).pairsDo({|name, controls| + controls.put(\active, false); + analyzer.stopAnalysisSynth(name); + gui.setCurrentToggleState(name, false); + }); + } + ); + }, + path: "/toggle_all", + srcID: NetAddr.new("127.0.0.1", NetAddr.langPort) + ); + // listen for address messages to change OSC addresses OSCdef.newMatching( key: \address, @@ -242,6 +270,7 @@ Bowelyzer{ gui.setupHubView(config.config); gui.setupForwardView(config.config); gui.setCurrentConfigFilePath(config.configFilePath); + gui.setCurrentGlobalToggleState(true); },{ ("Configuration could not be read: "++fileName).error; }); -- cgit v1.2.3-70-g09d2