aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2016-06-08 18:50:22 +0200
committerDavid Runge <dave@sleepmap.de>2016-06-08 18:50:22 +0200
commitfce6068d0bda6ba952cf0b92685d155453102814 (patch)
treedb5a8e037ba15a729af715a682d961c74289e45a
parent85c71e09ce3ab3ecf1acb92652b92c39bd63c6d2 (diff)
downloadbowelyzer-fce6068d0bda6ba952cf0b92685d155453102814.tar.gz
bowelyzer-fce6068d0bda6ba952cf0b92685d155453102814.tar.bz2
bowelyzer-fce6068d0bda6ba952cf0b92685d155453102814.tar.xz
bowelyzer-fce6068d0bda6ba952cf0b92685d155453102814.zip
BowelyzerOSCHub.sc: Now using OSCdef, to be able to overwrite functionality, once ie. the server addresses have changed. Implemented forward function, that forwards incoming OSC message to the globally specified forward address, if it's not send to the local sclang.
-rw-r--r--BowelyzerOSCHub.sc39
1 files changed, 25 insertions, 14 deletions
diff --git a/BowelyzerOSCHub.sc b/BowelyzerOSCHub.sc
index a2ec888..b73e201 100644
--- a/BowelyzerOSCHub.sc
+++ b/BowelyzerOSCHub.sc
@@ -1,5 +1,5 @@
BowelyzerOSCHub{
- var <hub, <forward, <synthServer, <synthServerListener;
+ var <hub, <forward, <synthServer;
*new{
arg config;
@@ -15,7 +15,7 @@ BowelyzerOSCHub{
init{
arg config;
this.setupNetAddressesFromConfig(config);
- this.addAnalysisListener(config);
+ this.setupSynthListener(config);
}
setupNetAddressesFromConfig{
@@ -25,28 +25,39 @@ BowelyzerOSCHub{
synthServer = BowelyzerOSCHub.getNetAddr(config.at("synthServerAddress"), config.at("synthServerPort"));
}
-// setup a new listener for SynthServerAddress:SynthServerPort
- addAnalysisListener{
+// setup OSCdef for SynthServerAddress:SynthServerPort
+ setupSynthListener{
arg config;
// listen for individual SendReply messages
config.at("names").do({|name|
- postln("Listening for messages called '/"++name++"' coming from scsynth.");
- //TODO: use OSCdef here to be able to use key and free
- synthServerListener = OSCFunc.newMatching(
- {|msg, time, addr, recvPort|
- postln(time.asString++": "++msg[0]++" (amplitude: "++msg[3]++"; pitch: "++msg[4]++"; has pitch: "++msg[5]++"; note on: "++msg[6]++")");
- if(msg[6] != 0.0,{
- postln(msg[0]++" (amplitude: "++msg[3]++"; pitch: "++msg[4]++"; has pitch: "++msg[5]);
- });
- },
+ postln("Listening for messages called '/"++name++"' coming from scsynth at "++synthServer.ip++":"++synthServer.port++".");
+ OSCdef.newMatching(
+ name.asSymbol,
+ {|msg, time, addr, recvPort| this.forwardToNetAddress(msg, time)},
'/'++name.asSymbol,
synthServer,
hub.port
);
+ OSCdef(name.asSymbol).enable;
});
}
- //TODO: add functions to modify OSC listener behavior
+ //forward a received OSC message to the globally specified forward address
+ forwardToNetAddress{
+ arg msg, time;
+ var name = msg[0],
+ amplitude = msg[3],
+ pitch = msg[4],
+ hasPitch = msg[5],
+ onsetDetect = msg[7];
+ if(forward.isLocal && (forward.port == NetAddr.langPort), {
+ postln(msg[0]++" (amplitude: "++amplitude++"; pitch: "++pitch++"; has pitch: "++hasPitch);
+ },{
+ forward.sendMsg(name,"/amplitude", amplitude, "/pitch", pitch, "/hasPitch", hasPitch, "/detect", onsetDetect);
+ });
+ }
+
+ //TODO: add functions to modify OSC listener behavior (what data to send from which channel)
}