Complete SuperCollider code for smol two-track EP released in may 2021.
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.

444 lines
11 KiB

2 months ago
  1. (
  2. /* ********************************************************************
  3. Ringer of Shkmeris Mta (Libido & Revolution)
  4. copyright 2021 by Luka Prinčič
  5. distribution and re-use allowed under conditions of PP:BY-SA-NC
  6. (Peer Production: Attribution - ShareAlike - NonCapitalist) Licence
  7. ******************************************************************** */
  8. s.waitForBoot({
  9. fork({
  10. "-----------------------------------------".postln;
  11. // load samples
  12. ~shkmeris.free;
  13. ~shkmeris = Buffer.readChannel(s,
  14. PathName.new(thisProcess.nowExecutingPath).pathOnly
  15. +/+ "trio_mandili_shkmeris_mta_60s.wav",
  16. channels:1);
  17. "-> loaded buffers ...".postln;
  18. s.sync;
  19. // SynthDefs ---------------------------------------------------
  20. SynthDef('mhh1',
  21. {
  22. arg gate = 1, amp = 0.1, pan = 0, outBus = 0,
  23. rls = 1, rls1 = 0.01, lpa = 1, hpa = 1, bpa = 1;
  24. var snd;
  25. snd = WhiteNoise.ar;
  26. snd = snd + (Pulse.ar(freq: Rand(5000!10, 15000)).sum * 0.2);
  27. snd = (
  28. LPF.ar(snd, Rand(500,2000)) * lpa * 4
  29. * LFSaw.ar(LFNoise1.ar(1/3).range(15,30)).range(LFNoise1.ar(1).range(0.2,0.9), 1)
  30. * EnvGen.ar(Env.perc(0, Rand(0.1, rls)), gate) )
  31. + (
  32. HPF.ar(snd, Rand(2000,15000)) * hpa
  33. * LFSaw.ar(LFNoise1.ar(1/3).range(15,30)).range(LFNoise1.ar(1).range(0.2,0.9), 1)
  34. * EnvGen.ar(Env.perc(0, Rand(0.1, rls)), gate) )
  35. + (
  36. BPF.ar(snd, Rand(1000,5000), 0.2) * bpa * 4
  37. * LFSaw.ar(LFNoise1.ar(1/3).range(15,30)).range(LFNoise1.ar(1).range(0.2,0.9), 1)
  38. * EnvGen.ar(Env.perc(0, Rand(0.1, rls)), gate) )
  39. ;
  40. snd = HPF.ar(snd, 200);
  41. snd = LPF.ar(snd, 13000);
  42. snd = snd * EnvGen.kr(Env.cutoff(rls), gate, doneAction:Done.freeSelf);
  43. snd = Pan2.ar(snd, pan);
  44. snd = snd * amp;
  45. Out.ar(outBus, snd);
  46. }
  47. ).add;
  48. SynthDef(\kick,
  49. {
  50. arg gate = 1, out = 0, amp = 0.1, release = 0.9, freq=50, pan = 0, cutoff = 500, fxout=0, hpf=0;
  51. var snd, env, fenv;
  52. freq = freq * Rand(0.98, 1.02);
  53. fenv = EnvGen.ar(Env([freq*4,freq],0.08,'cub'));
  54. snd = SinOsc.ar(freq: [fenv,fenv*2], mul:[1,0.4] ).sum;
  55. snd = snd * LFPulse.ar(24).range(0.7,1).lag(0.02);
  56. snd = snd + WhiteNoise.ar(0.3);
  57. snd = snd + SinOsc.ar(freq: [freq*2,freq*4], mul:EnvGen.ar(Env.perc(0, 0.2)) * 0.5).sum;
  58. snd = snd + LFTri.ar(freq: freq*4, mul:EnvGen.ar(Env.perc(0, 0.5)) * 0.3);
  59. snd = RLPF.ar(snd, cutoff, 0.7);
  60. snd = HPF.ar(snd, hpf);
  61. snd = snd.softclip;
  62. snd = snd * EnvGen.ar(Env.adsr(0, 0.05, 0.4, release, curve:'sqr'), gate: gate, doneAction:Done.freeSelf);
  63. snd = snd * amp * 5;
  64. snd = Pan2.ar(snd, pan);
  65. Out.ar(fxout, snd);
  66. Out.ar(out, snd);
  67. }
  68. ).add;
  69. SynthDef('ringer',
  70. {
  71. arg outBus = 0, amp = 0.1, freq = 140, gate = 1, pan = 0;
  72. var snd;
  73. freq = freq * LFNoise1.kr(1/10).range(1,1.01);
  74. snd = WhiteNoise.ar;
  75. snd = snd + Pulse.ar(
  76. freq: [freq, freq * 0.5, freq * 2] * SinOsc.ar(1).range(0.99,1.01),
  77. mul: 0.01 ).sum;
  78. snd = Resonz.ar(snd,
  79. [
  80. freq,
  81. freq * 1.5 * SinOsc.kr(4).range(0.99,1.02) ,
  82. freq * 1.75 * SinOsc.kr(4).range(0.99,1.02) ,
  83. freq * 0.75 * LFNoise1.kr(4).range(0.99,1.01),
  84. freq * 0.5 * LFNoise1.kr(4).range(0.99,1.01),
  85. freq * 2 * LFNoise1.kr(4).range(0.99,1.01)
  86. ], 0.001, [100,1,1,10,10,5]).sum * 0.5;
  87. snd = snd + LFTri.ar(freq/2*0.99, mul:0.03);
  88. snd = snd + Pulse.ar(freq/2*1.01, mul:0.005);
  89. snd = Limiter.ar(snd, 0.8);
  90. snd = snd * amp ;
  91. snd = snd * EnvGen.ar(Env.adsr(0.001, 0.2), gate, doneAction:2);
  92. Out.ar(outBus, snd);
  93. }
  94. ).add;
  95. SynthDef(\deciverbfx,
  96. {
  97. arg inBus, outBus = 0;
  98. var snd, input;
  99. input = In.ar(inBus,1);
  100. snd = Decimator.ar(input, LFNoise1.ar(1/5).range(500,10000));
  101. snd = snd * LFPulse.ar(10).range(LFNoise1.kr(1/10).range(0.5,0.9),1)
  102. * LFNoise1.kr(1/10).range(0.2,0.5);
  103. snd = snd + input;
  104. snd = RLPF.ar(snd, LFNoise1.ar(0.1).exprange(1000,10000), rq:0.8);
  105. snd = GVerb.ar(snd, 100);
  106. Out.ar(outBus, snd);
  107. }
  108. ).add;
  109. SynthDef(\revfx,
  110. {
  111. arg inBus, outBus = 0;
  112. var snd, input;
  113. input = In.ar(inBus,2);
  114. snd = GVerb.ar(input.sum, 100);
  115. Out.ar(outBus, snd);
  116. }
  117. ).add;
  118. SynthDef(\beep_sus,
  119. {
  120. arg outBus = 0, freq=440, gate=1, amp=0.1, sawamp = 0.1;
  121. var snd;
  122. snd = Pulse.ar(freq) + LFTri.ar(freq/ Rand(1.99,2.01)) + Saw.ar(freq * Rand(1.99,2.01), mul:sawamp);
  123. snd = snd * EnvGen.kr(Env.cutoff, gate, doneAction:Done.freeSelf);
  124. snd = snd * amp;
  125. Out.ar(outBus, snd);
  126. }
  127. ).add;
  128. SynthDef(\beep_sus_filt,
  129. {
  130. arg outBus = 0, freq=440, gate=1, amp=0.1, ffreq = 1000, fq = 0.5, pan=0;
  131. var snd;
  132. ffreq = EnvGen.ar(Env.adsr(0.001,0.05,0.5,0.1), gate, ffreq, ffreq/2);
  133. snd = Pulse.ar(freq) + Saw.ar(freq * Rand(0.99,1.01) * [2,4], mul:0.3) + LFTri.ar(freq);
  134. snd = RLPF.ar(snd, ffreq, fq);
  135. snd = snd * EnvGen.kr(Env.cutoff, gate, doneAction:Done.freeSelf);
  136. snd = snd * amp;
  137. snd = Splay.ar(snd, 1, 1, 0);
  138. Out.ar(outBus, snd);
  139. }
  140. ).add;
  141. SynthDef(\fxdly,
  142. {
  143. arg inBus, outBus = 0;
  144. var snd, input;
  145. input = In.ar(inBus,2);
  146. snd = input + CombN.ar(
  147. HPF.ar(input, 500),
  148. 1, [0.33,0.44], 5, 0.5 );
  149. Out.ar(outBus, snd);
  150. }
  151. ).add;
  152. SynthDef(\grenel,
  153. {
  154. arg outBus = 0, gate = 1, amp = 0.1, buf, pos = 0,
  155. atk = 1, rls = 1, rand = 0, frq = 0.1, rate = 1, ffreq = 450;
  156. var snd, gfreq = 200;
  157. snd = GrainBuf.ar(
  158. numChannels: 2,
  159. trigger: Impulse.ar(gfreq * LFNoise0.ar(gfreq).range(1, 0.8) ),
  160. dur: 0.2,
  161. sndbuf: buf,
  162. rate: rate,
  163. pos:
  164. ( LFNoise1.kr(frq).range(0,0.2) * rand ) +
  165. ( SinOsc.kr(frq).range(0,0.03) * (rand-1).abs )
  166. + pos
  167. * LFNoise0.ar(gfreq).range(1, 0.999), // rand position a bit
  168. pan: LFNoise1.ar(0.5) * 0.9
  169. );
  170. snd = LPF.ar(in: snd, freq: LFNoise1.ar(0.1).exprange(ffreq,15000));
  171. snd = snd * EnvGen.kr(Env([0,1,0], [atk,rls], [3,-3], 1), gate, doneAction:Done.freeSelf);
  172. snd = snd * amp;
  173. Out.ar(outBus, snd);
  174. }
  175. ).add;
  176. SynthDef(\subCut,
  177. {
  178. arg cutoff=85, inBus, outBus;
  179. var snd, in;
  180. in = In.ar(inBus, 2);
  181. snd = HPF.ar(in, cutoff);
  182. Out.ar(outBus, snd);
  183. }
  184. ).add;
  185. SynthDef(\limiter,
  186. {
  187. arg cutoff=70, amp = 0.5, threshold = 0.5, inBus, outBus ;
  188. var snd, in;
  189. in = In.ar(inBus, 2);
  190. snd = Limiter.ar(in, threshold) * amp;
  191. Out.ar(outBus, snd);
  192. }
  193. ).add;
  194. "-> loaded SynthDefs ...".postln;
  195. s.sync;
  196. // busses
  197. ~fxBus = Bus.audio(s, 1);
  198. ~fxBus2 = Bus.audio(s, 1);
  199. ~dlyBus = Bus.audio(s, 2);
  200. ~revBus = Bus.audio(s, 2);
  201. ~subBus = Bus.audio(s, 2);
  202. ~limitBus = Bus.audio(s, 2);
  203. "-> created busses ...".postln;
  204. s.sync;
  205. // Pbinds ---------------------------------------------------------
  206. ~granG = Pbind(*[
  207. instrument: \grenel,
  208. buf: ~shkmeris,
  209. dur: 14,
  210. frq: 0.01,
  211. rate: [0.983, 0.983/2, 0.983*2],
  212. amp:0.07 * [1, 1.5, 0.2],
  213. ffreq: 3000,
  214. pos: Pstutter(2, Pxrand([ 0.98, 0.81, 0.78, 0.77, 0.751, 0.689,
  215. 0.639, 0.62, 0.61, 0.52, 0.46, 0.3, 0.2 ], inf), inf),
  216. legato:1.1,
  217. outBus: ~dlyBus,
  218. ]);
  219. ~beepP = Pbind(*[
  220. instrument: \beep_sus,
  221. dur: 0.2, // quintuplets
  222. legato: 0.01,
  223. scale: Scale.minor,
  224. degree: Pseq([[-7,0], Pxrand([2,4,5,6],6)], inf), // 7 quintuplets
  225. detune: Pseg([0,1,3,1,0], 5, \cub, inf),
  226. mtranspose: Pseq([Pn(0, 7*3), Pn(2, 7*3), Pn(-2, 7*4)],inf),
  227. sawamp: Pseg([0,1,0], 40, \lin, inf),
  228. outBus: ~fxBus2,
  229. amp:0.1
  230. ]);
  231. ~ringP = Pbind(*[
  232. instrument: 'ringer',
  233. dur: 5,
  234. scale: Scale.minor,
  235. degree: Pseq([0,Prand([2,-2]), Prand([5,4])], inf),
  236. octave: [4,5,6],
  237. amp: [2,2,1] * 0.2,
  238. detune: Pxrand([0,1,2,3], inf),
  239. legato: 1,
  240. outBus: ~fxBus
  241. ]);
  242. ~bassP = Pbind(*[
  243. instrument: \beep_sus_filt,
  244. dur: Pseq([Pn(0.5, 112), Pn(0.4, 140)], inf),
  245. octave: Pseq([Pn([3,4],28), Pn([5,4],28), Pn([6,4],28)], inf),
  246. scale: Scale.minor,
  247. degree: Pseq([Pn(Pwrand([0,14],[0.95,0.05]),7),7],inf) * Pwhite(0.999,1.001),
  248. outBus:~dlyBus,
  249. legato: Pwhite(0.4,0.7),
  250. fq: Pseg([0.9,0.6,0.9], 17, \lin, inf),
  251. amp:0.07,
  252. ffreq: Pseg([500,2000,500], 10, \exp, inf),
  253. pan:0
  254. ]);
  255. ~kickP = Pbind(*[
  256. instrument: 'kick',
  257. dur: 1,
  258. degree:0,
  259. octave:[2,3],
  260. amp: [1,0.3] * 0.12,
  261. release: [0.9, 0.3],
  262. legato:0.6,
  263. outBus: ~limitBus,
  264. ]);
  265. ~hhP = Pbind(*[
  266. instrument: 'mhh1',
  267. dur: Pseq([Prand([1,2]),2,Prand([1,3,Pn(1/2,2)])] * 0.2, inf),
  268. rls: Pwrand([0.5, 2.5], [0.9,0.1], inf),
  269. bpa: 0.6,
  270. lpa: 0.1,
  271. hpa: 1,
  272. legato:0.1,
  273. pan: Pwhite(-0.2,0.2),
  274. outBus: ~subBus,
  275. ]);
  276. ~snP = Pbind(*[
  277. instrument: 'mhh1',
  278. dur: Pseq([Prand([4,6]),4,3] * 0.2, inf),
  279. rls: Pwrand([1, Pwhite(0.5,3.5)], [0.9,0.1], inf),
  280. bpa: 0,
  281. lpa: 2,
  282. hpa: 0,
  283. legato:0.1,
  284. outBus: ~subBus,
  285. ]);
  286. "-> loaded Pbindefs ...".postln;
  287. s.sync;
  288. // load fx to buses
  289. ~fx = Synth(\deciverbfx, [\inBus, ~fxBus, \outBus, ~subBus], addAction: \addToTail);
  290. ~fx2 = Synth(\deciverbfx, [\inBus, ~fxBus2, \outBus, ~subBus], addAction: \addToTail);
  291. ~dly = Synth(\fxdly, [\inBus, ~dlyBus, \outBus, ~subBus], addAction: \addToTail);
  292. ~rev = Synth(\revfx, [\inBus, ~revBus, \outBus, ~subBus], addAction: \addToTail);
  293. ~subCut = Synth(\subCut, [\inBus, ~subBus, \outBus, ~limitBus], addAction: \addToTail);
  294. ~limiter = Synth(\limiter, [\inBus, ~limitBus, \outBus, 0], addAction: \addToTail);
  295. "-> instantiated fx Synths ...".postln;
  296. // FINAL TIMELINE/SONG SEQUENCE
  297. s.sync;
  298. "-> starting final timeline / song sequence ...".postln;
  299. Pseq([
  300. Pfindur(14, Ppar([
  301. Pbindf(~kickP),
  302. ])),
  303. Pfindur(28, Ppar([
  304. Pbindf(~kickP),
  305. Pfindur(27, Pbindf(~snP)),
  306. ])),
  307. Pfindur(27.5, Ppar([
  308. Pbindf(~kickP),
  309. Pbindf(~snP),
  310. Pbindf(~hhP),
  311. ])),
  312. Rest(0.5),
  313. Pfindur(28 , Ppar([
  314. Pbindf(~beepP),
  315. ])),
  316. Pfindur(28, Ppar([
  317. Pbindf(~beepP),
  318. Pbindf(~kickP),
  319. ])),
  320. Pfindur(28, Ppar([
  321. Pbindf(~beepP),
  322. Pbindf(~kickP),
  323. Pbindf(~snP),
  324. ])),
  325. Pfindur(28, Ppar([
  326. Pbindf(~beepP),
  327. Pfindur(27, Ppar([
  328. Pbindf(~kickP),
  329. Pbindf(~snP),
  330. Pbindf(~hhP),]))
  331. ])),
  332. Pfindur(28, Ppar([
  333. Pbindf(~beepP),
  334. Pbindf(~granG, *[pos: 0.77]),
  335. Pbindf(~kickP),
  336. ])),
  337. Pfindur(8*14, Ppar([
  338. Pbindf(~bassP),
  339. Pbindf(~beepP),
  340. Pbindf(~kickP),
  341. Pbindf(~snP),
  342. Pbindf(~hhP),
  343. Pbindf(~granG, *[ pos:
  344. Pseq([0.52, 0.77, 0.2, 0.46 ], inf)
  345. ]),
  346. Pbindf(~ringP, *[ dur:Pseq([Rest(4*14), Pn(7)])] )
  347. ])),
  348. Pfindur(8*14, Ppar([
  349. Pfindur(4*14, Pbindf(~bassP)),
  350. Pbindf(~kickP),
  351. Pfindur(6*14, Pbindf(~snP)),
  352. Pbindf(~granG, *[ pos:
  353. Pseq([0.52, 0.77, 0.2, 0.46 ], inf)
  354. ]),
  355. Pbindf(~ringP, *[ dur: 7] )
  356. ])),
  357. Rest(6),
  358. Pfunc({ "-> final timeline / song sequence end.".postln; }),
  359. Pfunc({ CmdPeriod.run;}),
  360. //Pfunc({s.quit})
  361. ]).play;
  362. })
  363. });
  364. )