Always-on computer music
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

66 lignes
2.1KB

  1. // SVNVimStart
  2. s = Server.local;
  3. s.waitForBoot {
  4. var module, msg, modules;
  5. // Connect to OSC
  6. thisProcess.openUDPPort(5005);
  7. n = NetAddr.new("0.0.0.0", 5005);
  8. o = OSCFunc({ arg msg, time, addr, recvPort; [msg, time, addr, recvPort].postln; }, '/radio', n);
  9. // Create the synth definition and load it
  10. module = SynthDef.new(\module, {
  11. arg hue, saturation, value, pan, gain, octave;
  12. var oscillator, noise, filter, panner, mixer, frequency, qfactor, noise_level, osc_level, lagtime;
  13. // Calculate some parameters
  14. lagtime = 0.5;
  15. frequency = Lag.kr(200 + 300*hue, lagtime) * (2**octave);
  16. qfactor = Lag.kr((1 - saturation)**4, lagtime);
  17. osc_level = Lag.kr(saturation, lagtime);
  18. noise_level = Lag.kr(1 - osc_level, lagtime);
  19. // Generate some sounds
  20. // noise = WhiteNoise.ar(1);
  21. noise = Crackle.ar(1.99, 1.0);
  22. filter = BPF.ar(noise, frequency, qfactor) * noise_level;
  23. //oscillator = SinOsc.ar(frequency) * osc_level;
  24. oscillator = DPW3Tri.ar(frequency) * osc_level;
  25. mixer = Mix.ar([filter, oscillator]);
  26. panner = LinPan2.ar(mixer, pan, 10*HPF.kr(value, 10**(1-octave*2))**2);
  27. Out.ar(0, panner);
  28. });
  29. module.load(s);
  30. s.sync;
  31. // Create multiple sound generators
  32. modules = Array.fill(12,
  33. {
  34. arg index;
  35. var pan, octave;
  36. pan = ((index % 4) - 1.5)/1.5;
  37. octave = (index / 4).floor;
  38. "% %\n".postf(pan, octave);
  39. Synth.new(\module,
  40. [\hue, 0.5, \saturation, 0.1, \value, 0.5, pan, 0.5, \gain, 0.9, \octave, octave]
  41. )
  42. }
  43. );
  44. // Hook up OSC
  45. f = { |msg, time, addr|
  46. if(msg[0] == '/radio') {
  47. if(msg[1]<modules.size){
  48. modules[msg[1]].set(\hue, msg[2]);
  49. modules[msg[1]].set(\saturation, msg[3]);
  50. modules[msg[1]].set(\value, msg[4]);
  51. modules[msg[1]].set(\pan, msg[5]);
  52. }
  53. }
  54. };
  55. thisProcess.addOSCRecvFunc(f);
  56. };