A place to dump little or mid-sized snippets of SuperCollider code.
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.

214 lines
4.6 KiB

  1. ( // synthdefs
  2. SynthDef(\dlywrangler, {
  3. arg out=0, in;
  4. var snd;
  5. snd = In.ar(in,2);
  6. snd = CombL.ar(snd, 1, Lag.ar(LFNoise0.ar(1).range(0.01,0.1),0.01), 3, mul:0.1) + snd;
  7. Out.ar(out, snd);
  8. }).add;
  9. SynthDef(\wiDel, {
  10. var snd = In.ar(\in.kr, 2);
  11. snd = CombL.ar(snd, 1, SinOsc.ar(0.02,[0,pi/2]).range(0.5,0.6)+[0,0.22], 10, mul:1) + snd;
  12. Out.ar(\out.kr(0), snd);
  13. }).add;
  14. SynthDef(\softSaw, {
  15. arg out = 0, freq = 40, oscdetune = 0.1, amp = 1, pan = 0,
  16. gate = 1, attackTime = 0.1, susLevel = 1.0, releaseTime = 1.0;
  17. var env, snd;
  18. oscdetune = oscdetune * 0.1;
  19. amp = amp * 0.4;
  20. env = Linen.kr(gate, attackTime, susLevel, releaseTime, doneAction:2);
  21. snd = VarSaw.ar(
  22. freq: [freq, freq * (1.003 + oscdetune)],
  23. width: SinOsc.kr(0.01,0.2).range(0.05,0.095));
  24. snd = snd + VarSaw.ar(
  25. freq: [(freq*2 * (1.001 - oscdetune)),(freq*2 * (1 + oscdetune))],
  26. width: SinOsc.kr(0.06,0.8).range(0.2,0.8));
  27. snd = Balance2.ar(snd.at(0), snd.at(1), pos: pan);
  28. snd = snd * amp * env;
  29. Out.ar(out, snd);
  30. }).add;
  31. // "LFTri bass drum kick" - by luka@lukaprincic.si
  32. SynthDef(\tribd, {
  33. arg out=0, gate=1, freq=77, amp=0.1;
  34. var snd, aenv, fenv, senv;
  35. fenv = Env(levels:[2, 1, 0], times: [0.1, 0.5]).kr;
  36. freq = freq * fenv;
  37. freq = freq.max(10);
  38. snd = LFTri.ar(freq) + SinOsc.ar(freq);
  39. snd = LPF.ar(snd, freq * 4);
  40. snd = snd + RLPF.ar( BrownNoise.ar(1),
  41. Env(levels:[2000,500,90], times:[0.01,0.05]).kr, 0.3 );
  42. snd = snd + ( BPF.ar(WhiteNoise.ar(0.9), 3000)
  43. * Env([1,1,0], [0.004,0.005]).kr );
  44. snd = snd + ( BPF.ar(WhiteNoise.ar(0.1), 9000)
  45. * Env([1,1,0], [0.002,0.002]).kr );
  46. aenv = Env([1,1,0], [0.2,2], curve: -9).kr;
  47. snd = snd * aenv;
  48. senv = Linen.kr(releaseTime: 0.1, gate: gate, doneAction: Done.freeSelf);
  49. snd = LeakDC.ar(snd);
  50. snd = snd * amp * senv;
  51. snd = Pan2.ar(snd, pos:0);
  52. Out.ar(out, snd);
  53. }).add;
  54. // SC808 drum snare
  55. SynthDef.new(\sc808sn, {
  56. arg amp=2, tone=340, tone2=189, snappy=0.3, gate=0, amp2=1, out=0;
  57. var noiseEnv, atkEnv, sig, noise, osc1, osc2, sum;
  58. noiseEnv = EnvGen.kr(Env.perc(0.001, 4.2, 1, -115), doneAction:2);
  59. atkEnv = EnvGen.kr(Env.perc(0.001, 0.8,curve:-95), doneAction:0);
  60. noise = WhiteNoise.ar;
  61. noise = HPF.ar(noise, 1800);
  62. noise = LPF.ar(noise, 8850);
  63. noise = noise * noiseEnv * snappy;
  64. osc1 = SinOsc.ar(tone2, pi/2) * 0.6;
  65. osc2 = SinOsc.ar(tone, pi/2) * 0.7;
  66. sum = (osc1+osc2) * atkEnv * amp2;
  67. sig = Pan2.ar((noise + sum) * amp * 2.5, 0);
  68. sig = HPF.ar(sig, 340);
  69. Out.ar(out, sig);
  70. }).add;
  71. SynthDef.new(\sc808hh, {
  72. arg decay=0.42, amp=1, pan=0, out=0;
  73. var sig, sighi,siglow, sum, env, osc1, osc2, osc3, osc4, osc5, osc6;
  74. env = EnvGen.kr(Env.perc(0.005, decay, 1, -30),doneAction:2);
  75. osc1 = LFPulse.ar(203.52);
  76. osc2 = LFPulse.ar(366.31);
  77. osc3 = LFPulse.ar(301.77);
  78. osc4 = LFPulse.ar(518.19);
  79. osc5 = LFPulse.ar(811.16);
  80. osc6 = LFPulse.ar(538.75);
  81. sighi = (osc1 + osc2 + osc3 + osc4 + osc5 + osc6);
  82. siglow = (osc1 + osc2 + osc3 + osc4 + osc5 + osc6);
  83. sighi = BPF.ar(sighi, 8900, 1);
  84. sighi = HPF.ar(sighi, 9000);
  85. siglow = BBandPass.ar(siglow, 8900, 0.8);
  86. siglow = BHiPass.ar(siglow, 9000, 0.3);
  87. sig = BPeakEQ.ar((siglow+sighi), 9700, 0.8, 0.7);
  88. sig = sig * env * amp;
  89. sig = Pan2.ar(sig, pan);
  90. Out.ar(out, sig);
  91. }).add;
  92. // fx buses
  93. ~delay1 = Bus.audio(s, 2);
  94. ~delay2 = Bus.audio(s,2);
  95. /////////////////////////////////////////////////////////////////////
  96. // timeline of events
  97. r = Routine {
  98. 1.wait;
  99. // delays
  100. ~dlywrang1 = Synth(\dlywrangler, [\out, 0, \in, ~delay1]);
  101. ~widel1 = Synth(\wiDel, [\in, ~delay2, \out, 0]);
  102. 1.wait;
  103. (
  104. Pbindef(\x99,
  105. * [
  106. instrument: \tribd,
  107. octave:3,
  108. degree: Prand([1,2,3]/10,inf),
  109. dur: Pseq([3,2,Prand([2,3]),3,2,2]/8, inf),
  110. amp: 0.2
  111. ]
  112. ).play;
  113. );
  114. 7.wait;
  115. ( // snare
  116. Pbindef(\snp1,
  117. *[
  118. instrument: \sc808sn,
  119. dur: Pseq([Rest(1),Pxrand([1,1.5,0.5,Pn(0.5,4),Pn(0.25,2),Pn(0.25,2),Pn(0.25,2)])]/2,inf),
  120. amp: Prand([1,2,3]*0.05+0.2,inf),
  121. out: Prand([0,~delay1],inf)
  122. ]
  123. ).play;
  124. );
  125. 7.wait;
  126. ( // highhat
  127. Pbindef(\hhp1,
  128. * [
  129. instrument: \sc808hh,
  130. dur: 1/8,
  131. amp: Prand([1,2,3]/10, inf),
  132. out: Pwrand([~delay1,0],[0.7,0.3],inf),
  133. pan: Pfunc({rrand(-0.6,0.6)})
  134. ]
  135. ).play;
  136. );
  137. 21.wait;
  138. ( // dark saw
  139. Pbindef(\sawp1,
  140. *[
  141. instrument: \softSaw,
  142. dur: 10,
  143. attackTime: 5,
  144. releaseTime:5,
  145. legato:1,
  146. degree: Pseq([ [-2,3,11,20], [-2,5,7,21] ],inf),
  147. octave: 3,
  148. amp: [1,0.5,0.2,0.1] * 0.2,
  149. out: ~delay2
  150. ]
  151. ).play;
  152. );
  153. 77.wait;
  154. Pbindef(\hhp1).stop;
  155. 10.wait;
  156. Pbindef(\snp1).stop;
  157. 10.wait;
  158. Pbindef(\x99).stop;
  159. 10.wait;
  160. Pbindef(\sawp1).stop;
  161. }.play;
  162. );