El MuCo: Server Code
Follows the testing code:
/* El MuCo "Server"
169.254.136.163 - Powerbook self-assigned IP
to reset the environment (clear everything - all responders, senders, etc.)
currentEnvironment.clear;
*/
s.boot;
SynthDef("kane", { |freq = 40|
Out.ar([0,1], SinOsc.ar(freq));
}).send(s);
// SERVER: set the broadcast flag to true
NetAddr.broadcastFlag_(true)
//169.254.255.255 = broadcast IP: 57120 is sclang default port
~server = NetAddr("169.254.255.255", 57120);
// CLOCK: this clock is from the OSCClock quark. Must install first
~clock = OSCClockSender.default.targets = [NetAddr("169.254.255.255", 57120)];
~clock = OSCClockSender.default.start;
/* Use this code to receive the messages and post...
~clockReceiver = OSCClockReceiver.new
~clockReceiver.verbose = true;
currentEnvironment.dump; // see what's in it
currentEnvironment.clear // clear what's in it... everything, caution
*/
// RESPONDERS to incoming messages: basically amounts to message-forwarding
x = Synth("kane");
~kane = OSCresponderNode(nil, '/bkane', { |time, resp, msg|
("Brian:" + msg).postln;
msg.removeAt(0);
x.set("freq", msg.at(1));
~server.sendMsg('/kane', *msg) } ).add;
// ~kane.remove;
~kitten = OSCresponderNode(nil, '/jkitten', { |time, resp, msg|
msg.postln;
msg.removeAt(0);
~server.sendMsg('/kitten', *msg) } ).add;
// ~kitten.remove;
~kling = OSCresponderNode(nil, '/mkling', { |time, resp, msg|
msg.postln;
msg.removeAt(0);
~server.sendMsg('/kling', *msg) } ).add;
// ~kling.remove;
~ky = OSCresponderNode(nil, '/kya', { |time, resp, msg|
msg.postln;
msg.removeAt(0);
~server.sendMsg('/ky', *msg) } ).add;
// ~ky.remove;
~dusty = OSCresponderNode(nil, '/sdusty', { |time, resp, msg|
msg.postln;
msg.removeAt(0);
x.set("freq", msg.at(1)); // remove later
~server.sendMsg('/dusty', *msg) } ).add;
// ~dusty.remove;
// CHAT
// TESTING
// must have a "responder" set to receive the message type '/test'
~server.sendMsg('/test', "You rock the half and half-c*cked");
currentEnvironment.clear;
Int8Array
And something to receive the messages in SC
o = OSCresponderNode(nil, '/test', { |t, r, msg| msg.at(0).postln }).add;
o.remove;