aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
}
}