|
- s = Server.local;
- s.waitForBoot {
- var module, msg, modules;
-
-
- thisProcess.openUDPPort(5005);
- n = NetAddr.new("0.0.0.0", 5005);
- o = OSCFunc({ arg msg, time, addr, recvPort; [msg, time, addr, recvPort].postln; }, '/radio', n);
-
-
- module = SynthDef.new(\module, {
- arg hue, saturation, value, pan, gain;
- var oscillator, noise, filter, panner, mixer, frequency, qfactor, noise_level, osc_level;
-
-
- frequency = 800 + 500*hue;
- qfactor = (1 - saturation)**4;
- osc_level = saturation;
- noise_level = 1 - osc_level;
-
-
-
- noise = Crackle.ar(1.9, 1.0);
- filter = BPF.ar(noise, frequency, qfactor) * noise_level;
- oscillator = SinOsc.ar(frequency) * osc_level;
- mixer = Mix.ar([filter, oscillator]);
- panner = LinPan2.ar(mixer, 2*pan - 1, value * 0.2);
- Out.ar(0, panner);
- });
- module.load(s);
- s.sync;
-
-
- modules = Array.fill(12,
- {
- arg index;
- var pan;
- pan = ((index % 4) - 1.5)/1.5;
- Synth.new(\module,
- [\hue, 0.5, \saturation, 0.1, \value, 0.5, pan, 0.5, \gain, 0.9]
- )
- }
- );
-
- "%\n".postf(modules[0]);
- "%\n".postf(modules[1]);
-
-
- f = { |msg, time, addr|
- if(msg[0] == '/radio') {
- "Got data: index: % hue: % sat: % value: % pan: %\n".postf(msg[1], msg[2], msg[3], msg[4], msg[5]);
- if(msg[1]<modules.size){
- "Applying to module %\n\n".postf(msg[1]);
- modules[msg[1]].set(\hue, msg[2]);
- modules[msg[1]].set(\saturation, msg[3]);
- modules[msg[1]].set(\value, msg[4]);
- modules[msg[1]].set(\pan, msg[5]);
- }
- }
- };
- thisProcess.addOSCRecvFunc(f);
- };
|