Always-on computer music
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

audio.scd 1.5KB

3 lat temu
3 lat temu
3 lat temu
3 lat temu
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. s = Server.local;
  2. s.waitForBoot {
  3. var module, sound, msg;
  4. // Connect to OSC
  5. thisProcess.openUDPPort(5005);
  6. n = NetAddr.new("0.0.0.0", 5005);
  7. o = OSCFunc({ arg msg, time, addr, recvPort; [msg, time, addr, recvPort].postln; }, '/radio', n);
  8. //OSCFunc.trace(true);
  9. // Create the synth definition and load it
  10. module = SynthDef.new("module", {
  11. arg hue, saturation, value, pan;
  12. var oscillator, noise, filter, panner, mixer, frequency, qfactor, noise_level, osc_level;
  13. // Calculate some parameters
  14. frequency = 200 + 800*hue;
  15. qfactor = (1 - saturation)**4;
  16. osc_level = saturation;
  17. noise_level = 1 - osc_level;
  18. // Generate some sounds
  19. noise = WhiteNoise.ar(1);
  20. filter = BPF.ar(noise, frequency, qfactor) * noise_level;
  21. oscillator = SinOsc.ar(frequency) * osc_level;
  22. mixer = Mix.ar([filter, oscillator]);
  23. panner = LinPan2.ar(mixer, 2*pan - 1, value);
  24. Out.ar(0, panner);
  25. });
  26. module.load(s);
  27. s.sync;
  28. // Make a sound
  29. sound = Synth.new("module", [\hue, 0.5, \saturation, 0.1, \value, 0.5, \pan, 0.5]);
  30. // Hook up OSC
  31. f = { |msg, time, addr|
  32. if(msg[0] == '/radio') {
  33. "Got data: % % % % %".postf(msg[1], msg[2], msg[3], msg[4], msg[5]);
  34. sound.set("hue", msg[1]);
  35. sound.set("saturation", msg[2]);
  36. sound.set("value", msg[3]);
  37. sound.set("pan", msg[4]);
  38. }
  39. };
  40. thisProcess.addOSCRecvFunc(f);
  41. };