aboutsummaryrefslogtreecommitdiffstats
path: root/BowelyzerOSCHub.sc
diff options
context:
space:
mode:
Diffstat (limited to 'BowelyzerOSCHub.sc')
-rw-r--r--BowelyzerOSCHub.sc47
1 files changed, 47 insertions, 0 deletions
diff --git a/BowelyzerOSCHub.sc b/BowelyzerOSCHub.sc
new file mode 100644
index 0000000..028de55
--- /dev/null
+++ b/BowelyzerOSCHub.sc
@@ -0,0 +1,47 @@
+BowelyzerOSCHub{
+ var <>config, <hub, <forward, <synthServer, <synthServerListener;
+
+ *new{
+ arg config;
+ ^super.new.init(config);
+ }
+
+ // setup a NetAddr object and return it
+ *getNetAddr{
+ arg server, port;
+ ^NetAddr.new(server, port);
+ }
+
+ init{
+ arg config;
+ this.config = config;
+ forward = BowelyzerOSCHub.getNetAddr(config.at("forwardAddress"), config.at("forwardPort"));
+ hub = BowelyzerOSCHub.getNetAddr(config.at("hubAddress"), config.at("hubPort"));
+ synthServer = BowelyzerOSCHub.getNetAddr(config.at("synthServerAddress"), config.at("synthServerPort"));
+ this.addAnalysisListener;
+ }
+
+
+// setup a new listener for SynthServerAddress:SynthServerPort
+ addAnalysisListener{
+ // 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]);
+ });
+ },
+ '/'++name.asSymbol,
+ synthServer,
+ hub.port
+ );
+ });
+ }
+
+ //TODO: add functions to set arguments for analyzer synths generically
+
+} \ No newline at end of file