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.

dev.scd 1.5KB

3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. s = Server.local;
  2. s.waitForBoot {
  3. var synth, module;
  4. // Create the synth definition and load it
  5. module = SynthDef.new("module", {
  6. var x;
  7. var frequency, qfactor, fm_amount, detune, distortion, oscillator_level, subosc_level, noise_level, noise_tone;
  8. var detune_max = 3;
  9. var noise, crackle, mnoise, fnoise, rootosc, fmosc, subosc, msin, dsin, mixer, panner;
  10. // Setup some parameters
  11. x = MouseY.kr(0, 1);
  12. frequency = 1000;
  13. qfactor = ((0 -x) * 10).exp;
  14. detune = (1 - x) * detune_max;
  15. fm_amount = 1 - x;
  16. distortion = (1 - x)**2;
  17. subosc_level = 1 - (x-0.5)**2;
  18. oscillator_level = x**4;
  19. noise_level = 0.1 * (1 - (x - 0.5)**2);
  20. noise_tone = 1 - x;
  21. // Build and connect noise modules
  22. noise = WhiteNoise.ar(noise_level);
  23. crackle = Crackle.ar(noise_tone + 1, 0.5);
  24. mnoise = Mix.ar([crackle]) * (1-x);
  25. fnoise = BPF.ar(mnoise, frequency, qfactor);
  26. // Build and connect sinusoid modules
  27. fmosc = SinOsc.ar(frequency * 0.3);
  28. rootosc = SinOsc.ar(frequency + fmosc) * oscillator_level;
  29. subosc = SinOsc.ar(frequency/16).cubed * subosc_level;
  30. // Mix the sines together
  31. msin = Mix.ar([subosc]);
  32. // Distort the sines
  33. dsin = msin;
  34. mixer = Mix.ar([dsin, fnoise]);
  35. panner = LinPan2.ar(mixer, MouseX.kr(-1, 1), 1);
  36. Out.ar(0, panner);
  37. });
  38. module.load(s);
  39. s.sync;
  40. synth = Synth.new("module");
  41. };