|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- s = Server.local;
- s.waitForBoot {
- var module, sound, msg;
-
- // Connect to OSC
- 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);
- //OSCFunc.trace(true);
-
- // Create the synth definition and load it
- module = SynthDef.new("module", {
- arg hue, saturation, value, pan;
- var oscillator, noise, filter, panner, mixer, frequency, qfactor, noise_level, osc_level;
-
- // Calculate some parameters
- frequency = 200 + 800*hue;
- qfactor = (1 - saturation)**4;
- osc_level = saturation;
- noise_level = 1 - osc_level;
-
- // Generate some sounds
- noise = WhiteNoise.ar(1);
- 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);
- Out.ar(0, panner);
- });
- module.load(s);
- s.sync;
-
- // Make a sound
- sound = Synth.new("module", [\hue, 0.5, \saturation, 0.1, \value, 0.5, \pan, 0.5]);
-
- // Hook up OSC
- f = { |msg, time, addr|
- if(msg[0] == '/radio') {
- "Got data: % % % % %".postf(msg[1], msg[2], msg[3], msg[4], msg[5]);
- sound.set("hue", msg[1]);
- sound.set("saturation", msg[2]);
- sound.set("value", msg[3]);
- sound.set("pan", msg[4]);
- }
- };
- thisProcess.addOSCRecvFunc(f);
- };
|