Always-on computer music
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

dev.scd 2.2KB

3年前
3年前
3年前
3年前
3年前
3年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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, output, dust;
  13. // Dynamic time of the module
  14. lagtime = 100 / (2**octave);
  15. // Oscillator/filter frequency
  16. frequency = 130 + (hue * 130) * (2 ** octave);
  17. frequency = Lag.kr(frequency, lagtime);
  18. // Filtered saw oscillator
  19. oscillator = SawDPW.ar(frequency);
  20. filter = DFM1.ar(oscillator, frequency*0.8, 0.8, 1.0, 0.0, 0.0006);
  21. // Apply pan
  22. panner = LinPan2.ar(filter, pan);
  23. // Apply dynamics
  24. output = panner * Lag.kr(HPF.kr(value, hue / (lagtime)), lagtime*4);
  25. //output = panner * BPF.kr(value, 1 / lagtime, 100);
  26. // Compress
  27. output = Compander.ar(output, output, 0.5, 0.3, 0.3, 0.1, lagtime);
  28. // Crank everything down
  29. output = output * 0.1;
  30. Out.ar(0, output);
  31. });
  32. module.load(s);
  33. s.sync;
  34. // Create multiple sound generators
  35. modules = Array.fill(12,
  36. {
  37. arg index;
  38. var pan, octave;
  39. pan = 0 - ((index % 4) - 1.5)/1.5;
  40. octave = (2 - (index / 4).floor);
  41. "Module %: Pan %, octave %\n".postf(index, pan.round(1e-1), octave.round(1e-1));
  42. Synth.new(\module,
  43. [\hue, 0.5, \saturation, 0.1, \value, 0.5, \pan, pan, \gain, 0.9, \octave, octave]
  44. )
  45. }
  46. );
  47. // Hook up OSC
  48. f = { |msg, time, addr|
  49. if(msg[0] == '/radio') {
  50. if(msg[1]<modules.size){
  51. modules[msg[1]].set(\hue, msg[2]);
  52. modules[msg[1]].set(\saturation, msg[3]);
  53. modules[msg[1]].set(\value, msg[4]);
  54. }
  55. }
  56. };
  57. thisProcess.addOSCRecvFunc(f);
  58. };