Always-on computer music
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

audio.scd 2.5KB

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