aboutsummaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2016-08-09 15:23:39 +0200
committerDavid Runge <dave@sleepmap.de>2016-08-09 15:23:39 +0200
commitc83c7c1fe4186747ab99c7d05401f60be0241147 (patch)
tree7d0984622eb579b05625220f64f1392ba12d41f2 /classes
parent12c4549cd2b9e2ddfac8999ea6c8e5982de2743c (diff)
downloadbowelyzer-1.0.3.tar.gz
bowelyzer-1.0.3.tar.bz2
bowelyzer-1.0.3.tar.xz
bowelyzer-1.0.3.zip
classes/Bowelyzer.sc: Adding a postLocally function to postln the received OSC message. Adding a verbose variable, that will be used to post output, when set to true, to minimize the overall bowelyzer output. Refactoring most of forwardToNetAddress back to the per channel OSCdefs: The overall logic now takes place in there and functionality is further externalized into functions.1.0.3
Diffstat (limited to 'classes')
-rw-r--r--classes/Bowelyzer.sc83
1 files changed, 46 insertions, 37 deletions
diff --git a/classes/Bowelyzer.sc b/classes/Bowelyzer.sc
index 2ff1a5c..be48cd0 100644
--- a/classes/Bowelyzer.sc
+++ b/classes/Bowelyzer.sc
@@ -1,15 +1,25 @@
Bowelyzer{
- var <gui, <server, <analyzer, <config, <hubAddr, <forwardAddr, <localAddr, <synthServerAddr;
+ var <gui,
+ <server,
+ <analyzer,
+ <config,
+ <hubAddr,
+ <forwardAddr,
+ <localAddr,
+ <synthServerAddr,
+ <hasGUI,
+ <>verbose;
*new{
- arg configFile;
- ^super.new.init(configFile);
+ arg configFile, verbose = false;
+ ^super.new.init(configFile, verbose);
}
init{
//initialize with configuration, if available (else use default)
- arg configFile;
+ arg configFile, verbose;
+ this.verbose = verbose;
config = BowelyzerConfig.new(configFile);
this.addServer;
server.waitForBoot({
@@ -449,7 +459,30 @@ Bowelyzer{
OSCdef.newMatching(
key: name.asSymbol,
func: {|msg, time, addr, recvPort|
- this.forwardToNetAddress(msg, time);
+ var name = msg[0],
+ sanitizedName = name.asString.replace("/","").asSymbol,
+ amplitude = msg[3],
+ pitch = msg[4],
+ hasPitch = msg[5],
+ onsetDetect = msg[6],
+ range = config.config.at(\controls).at(sanitizedName).at(\freqRange),
+ onlyForwardOnNewPitch = config.config.at(\controls).at(sanitizedName).at(\onlyForwardOnNewPitch);
+ // if there is something connected
+ if(amplitude != 0,{
+ // if the pitch is within freqRange
+ if((pitch >= range[0]) && (pitch <= range[1]),{
+ if(onlyForwardOnNewPitch.not || (onlyForwardOnNewPitch && (hasPitch > 0)), {
+ localAddr.sendMsg("/indicate", sanitizedName);
+ if(this.verbose,{this.postLocally(name, amplitude, pitch, hasPitch, onsetDetect)});
+ try{
+ this.forwardToNetAddress(name, amplitude, pitch, hasPitch, onsetDetect);
+ }{
+ if(this.verbose,{error("Couldn't send to NetAddr: "++forwardAddr)});
+ gui.pingForwardIndicator;
+ }
+ });
+ });
+ });
},
path: "/"++name.asString,
srcID: synthServerAddr,
@@ -472,39 +505,15 @@ Bowelyzer{
OSCdef(name.asSymbol).free;
}
+ //post a received OSC message locally
+ postLocally{
+ arg name, amplitude, pitch, hasPitch, onsetDetect;
+ postln("[ "++name++", "++amplitude++", "++pitch++", "++hasPitch++", "++onsetDetect++" ]");
+ }
+
//forward a received OSC message to the globally specified forward address
forwardToNetAddress{
- arg msg, time;
- var name = msg[0],
- sanitizedName = name.asString.replace("/","").asSymbol,
- amplitude = msg[3],
- pitch = msg[4],
- hasPitch = msg[5],
- onsetDetect = msg[6],
- range = config.config.at(\controls).at(sanitizedName).at(\freqRange),
- onlyForwardOnNewPitch = config.config.at(\controls).at(sanitizedName).at(\onlyForwardOnNewPitch);
- // if there is something connected
- if(amplitude != 0,{
- // if the pitch is within freqRange
- if((pitch >= range[0]) && (pitch <= range[1]),{
- if(onlyForwardOnNewPitch, {
- if(hasPitch > 0, {
- localAddr.sendMsg("/indicate", sanitizedName);
- if((forwardAddr.ip == "127.0.0.1") && (forwardAddr.port == NetAddr.langPort), {
- postln(name++": amplitude: "++amplitude++"; pitch: "++pitch++"; hasPitch: "++hasPitch++"; onSet: "++onsetDetect);
- },{
- forwardAddr.sendMsg(name, amplitude, pitch, hasPitch, onsetDetect);
- });
- });
- },{
- localAddr.sendMsg("/indicate", sanitizedName);
- if((forwardAddr.ip == "127.0.0.1") && (forwardAddr.port == NetAddr.langPort), {
- postln(name++": amplitude: "++amplitude++"; pitch: "++pitch++"; hasPitch: "++hasPitch++"; onSet: "++onsetDetect);
- },{
- forwardAddr.sendMsg(name, amplitude, pitch, hasPitch, onsetDetect);
- });
- });
- });
- });
+ arg name, amplitude, pitch, hasPitch, onsetDetect;
+ forwardAddr.sendMsg(name, amplitude, pitch, hasPitch, onsetDetect);
}
}