Smol or mid-sized snippets of SuperCollider code that start in SuperCollider's Workspace Emacs buffer from scratch.
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.

132 lines
3.1 KiB

  1. // posted this earlier this year at
  2. // http://sccode.org/1-5cM
  3. // and this is now a combination of above and variations at
  4. // http://sccode.org/1-5cR and http://sccode.org/1-5cQ
  5. // SynthDefs, buses, tempoclock:
  6. (
  7. SynthDef("plucking", {arg out = 0, amp = 0.1, freq = 440, decay = 5, coef = 0.1;
  8. var env, snd;
  9. env = EnvGen.kr(Env.linen(0, decay, 0), doneAction: 2);
  10. snd = Pluck.ar(
  11. in: PinkNoise.ar(amp),
  12. trig: Impulse.kr(0),
  13. maxdelaytime: 0.1,
  14. delaytime: freq.reciprocal,
  15. decaytime: decay,
  16. coef: coef);
  17. snd = LeakDC.ar(snd).clip2;
  18. Out.ar(out, snd * env);
  19. }).add;
  20. SynthDef("reverbBus", { arg outBus = 0, inBus, wet = 0.5;
  21. var input, rev;
  22. input = In.ar(inBus,1);
  23. rev = JPverb.ar(input * wet, t60:3);
  24. Out.ar(outBus, input + rev);
  25. }).add;
  26. // create separate bus for send->reverb
  27. b = Bus.audio(s,1);
  28. // tempoclock.
  29. t = TempoClock.default;
  30. )
  31. /////////////////////////////////////////////////////////////////////////////////////
  32. // variation 2
  33. (
  34. r = Synth("reverbBus", [\inBus, b, \wet, 0.5]);
  35. t.tempo_(80/60); // beats per minute
  36. Pbind(
  37. \instrument, "plucking",
  38. \scale, Scale.major.tuning_(\just),
  39. \octave, 4,
  40. \degree, Pseq([1,3,7,8], inf), // four main notes
  41. \mtranspose, Pseq([Pseq([0],3),Pseq([-5],3)],inf), // switched mode every 3 notes (*2)
  42. \gtranspose, Pseq([Pseq([0],36),Pseq([4],36),Pseq([[-3]],36),Pseq([2],36)],inf),
  43. \ctranspose, Pser([Pseries(-4,1,6) +.x Pseq([0], 144)],1),
  44. \coef, Pser([Prand([0.2,0.3,0.4,0.5],1), Prand([0.8,0.7,0.6,0.5],11)], inf),
  45. \dur, Prand([0.25,0.26,0.24,0.255,0.255,0.25], 240),
  46. \decay, Prand([1,2,3,4,5], inf),
  47. \out, b, \amp, 0.4,
  48. ).play;
  49. )
  50. /////////////////////////////////////////////////////////////////////////////////////
  51. // variation 1
  52. (
  53. ~reverb = Synth("reverbBus", [\inBus, b, \wet, 0.6]);
  54. t.tempo_(60/60);
  55. Pbind(
  56. \instrument, "plucking",
  57. \out, b,
  58. \scale, Scale.major.tuning_(\just),
  59. \octave, 4,
  60. \degree, Pseq([1,3,7,8,Prand([7,10,11,13,14]),8,7,3], inf),
  61. \dur, Pseq(
  62. [
  63. Pwrand([
  64. Pseq([0.2,0.2]),
  65. //0.2,
  66. 0.4,
  67. Pseq([0.1],4),
  68. Pseq([0.05],4)
  69. ],
  70. [0.5,0.3,0.1,0.1] // weights
  71. )
  72. ],
  73. 240),
  74. \coef, Pwrand([0.8, 0.6, 0.4, 0.2], [0.4,0.3,0.2,0.1], inf),
  75. \amp, 0.4,
  76. \addAction, 0, // make sure new synths are added to head of group (optional)
  77. ).play;
  78. )
  79. /////////////////////////////////////////////////////////////////////////////////////
  80. // variation 3
  81. (
  82. r = Synth("reverbBus", [\inBus, b, \wet, 0.5]);
  83. t.tempo_(1); //
  84. Pbind(
  85. \instrument, "plucking",
  86. \scale, Scale.major.tuning_(\just),
  87. \octave, 4,
  88. \degree, Pseq([1, 3, 7, 3,-4,-2, 7, 8, 1,-2, 2, 3], inf),
  89. \mtranspose, Pseq([Pseq([0],144),Pseq([0],48),Pseq([3],48),Pseq([4],48)], inf),
  90. \gtranspose, Pseq([Pseq([0],36),Pseq([4],36),Pseq([[-3]],36),Pseq([2],36)],inf),
  91. \ctranspose, Pser([Pseries(-4,1,4) +.x Pseq([0], 144)],2),
  92. \coef, Pseq([ Pseq([
  93. Prand([0.2,0.3,0.4,0.5],1),
  94. Prand([0.6,0.5],5),
  95. Prand([0.2,0.3],1),
  96. Prand([0.6,0.5],5)
  97. ], 1),
  98. Prand([0.7,0.6],12)
  99. ],inf),
  100. \dur, Pseq([Prand([0.25,0.25,0.24,0.245,0.255,0.25], 140),0.26,0.3,0.4,0.7], inf)
  101. * Pseq([Pseq([0.8],110), Pgeom(0.8,1.002,34)],inf),
  102. \decay, Pseq([8, Prand([1,2,3,4], 4),3,2,1], inf),
  103. \out, b, \amp, 0.4,
  104. ).play;
  105. )