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.

366 lines
10 KiB

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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. (/*
  2. Copyright (c) 2018 Luka Prinčič, All rights reserved.
  3. This program is free software distributed under
  4. GNU General Public Licence. See COPYING for more info.
  5. - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  6. This is source code to Antigone/Child music release and
  7. soundtrack to the stage piece by Matija Ferlin "Staging
  8. a Play: Antigone" by Luka Prinčič. It replicates 6
  9. tracks from the album and 6 tracks from the stage show.
  10. If you openned this file in SuperCollider IDE, there are
  11. two steps you have to do:
  12. PART I:
  13. Place the cursos anywhere between top parenthesis
  14. and the closing one, which is the one above the line
  15. that sais "Cooking Synths". In fact your cursor might
  16. already at the begining of this file, which means you can
  17. press CTRL+RETURN to run this part of code - booting and
  18. preparing server. The code will flash, there is no sound
  19. yet.)
  20. PART II:
  21. Scroll down to "Cooking Synths" and place the cursor inside
  22. the first block (ACT I), and press CTRL+RETURN again. The
  23. code will flash and slowly the sound should come in. If not,
  24. check with CTRL+M to see meters and SC output visualy.
  25. The piece will run out in about 5 minutes. Or you can
  26. always stop it with CTRL+<PERIOD>. And run the next block.
  27. Then play with parameters, break the code, start again.
  28. Make music!
  29. */
  30. // Be nice. Say hi!
  31. postln("\n\n
  32. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  33. >>> Hello. <<<
  34. _ _ _ _____ ___ ___ ___ _ _ ___ _____ _ _ ___ _ ___
  35. /_\\ | \\| |_ _|_ _/ __|/ _ \\| \\| | __| / / __| || |_ _| | | \
  36. / _ \\| .` | | | | | (_ | (_) | .` | _| / / (__| __ || || |__| |) |
  37. /_/ \\_\\_|\\_| |_| |___\\___|\\___/|_|\\_|___/_/ \\___|_||_|___|____|___/
  38. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  39. ");
  40. Server.default.waitForBoot { // if the SC server is not yet booted, boot it
  41. // home folder of current script
  42. var dir = PathName(thisProcess.nowExecutingPath).pathOnly;
  43. // find samples locations
  44. ~granSmp = PathName(dir +/+ "smp/").files;
  45. ~granBfrList = List();
  46. ~granBfr = List();
  47. // be nice and verbose in the post window while loading to buffers
  48. postln(" \n~~~ Loading samples for granular synthesis ..." );
  49. ~granSmp.do({ |item, i|
  50. postln(" " + i + "" + item.folderName +/+ item.fileName);
  51. ~granBfrList.add(item.fileName);
  52. ~granBfr.add(Buffer.readChannel(s, item.fullPath, channels:[0])); // [0] forces mono!
  53. });
  54. //////////////////////////////////////////////////////////////////////////////////////
  55. // granulator "Granny" synth definition - basic recipe for the cake
  56. SynthDef(\Granny, {
  57. // arguments - accessible/settable from outside
  58. arg bufnum,
  59. freq = 200, fvar = 0.05,
  60. dur = 0.3, durvar = 0.01,
  61. pitch = 1, pitchvar = 0.001,
  62. width = 0.4,
  63. gain = 0.2,
  64. reverb = 0.5,
  65. posvar = 0.05,
  66. // lpfLFO changes the frequency of low pass filter using a slow sine oscilator
  67. lpfLFOSpeed = 0.013, // frequency of the oscilator
  68. lpfLFOSpeedVar = 0.1, // varies the freq of the LF oscilator
  69. lpfLFOMin = 400, // from Hz
  70. lpfLFOMax = 5000, // to Hz
  71. // lpfLFO changes the position of granulation using a slow sine oscilator
  72. posLFOSpeed = 0.005,
  73. posLFOSpeedVar = 0.1,
  74. posLFOMin = 0,
  75. posLFOMax = 1
  76. ;
  77. // variables
  78. var signal,
  79. lpfFreq = SinOsc.kr(freq:lpfLFOSpeed * SinOsc.kr(freq:lpfLFOSpeedVar, mul:0.5, add:1)).linlin(
  80. inMin:-1, inMax:1, outMin:lpfLFOMin, outMax:lpfLFOMax),
  81. pos = SinOsc.kr(freq:posLFOSpeed * SinOsc.kr(freq:posLFOSpeedVar, mul:0.5, add:1)).linlin(
  82. inMin:-1, inMax:1, outMin:posLFOMin, outMax:posLFOMax),
  83. // envelopes
  84. gainEnv = Env.newClear(4),
  85. gainEnvCtl = \gainEnv.kr(gainEnv.asArray),
  86. lpfEnv = Env.newClear(4),
  87. lpfEnvCtl = \lpfEnv.kr(lpfEnv.asArray)
  88. ;
  89. // main granular synthesis generator: GrainBuf uGen
  90. signal = GrainBuf.ar(
  91. numChannels: 2, // stereo
  92. trigger: Impulse.kr(freq + (freq * (fvar * LFNoise2.kr(freq)))), // a UGen
  93. dur: dur + (durvar * LFNoise2.kr(freq)), // in seconds
  94. sndbuf: bufnum,
  95. rate: pitch + (pitchvar * LFNoise2.kr(5)), // pitch
  96. pos: pos + (posvar * LFNoise2.kr(freq)), // position 0-1
  97. interp: 2, // interpolation for pitchshifting
  98. pan: LFNoise1.kr(10).range(width.neg, width),
  99. maxGrains: 512,
  100. mul: gain,
  101. add: 0
  102. );
  103. // low pass filter
  104. signal = LPF.ar(
  105. in: signal,
  106. // prevent filter clicks by lagging low pass filter freq changes
  107. freq: Lag.kr(lpfFreq, 0.2)
  108. * EnvGen.kr(envelope: lpfEnvCtl, gate: 1)); // filter frequency envelope
  109. // fade in, sustain, fade out
  110. signal = signal * EnvGen.kr(envelope: gainEnvCtl, gate: 1, doneAction: 2);
  111. // reverb
  112. signal = GVerb.ar(
  113. in: signal,
  114. roomsize: 243,
  115. revtime: 6,
  116. damping: 1,
  117. inputbw: 1,
  118. drylevel: -6.dbamp,
  119. earlyreflevel: reverb,
  120. taillevel: 0.dbamp
  121. );
  122. Out.ar(0, signal);
  123. postln("~~~ adding SynthDef: Granny ...");
  124. }).add; // add to server
  125. }
  126. )
  127. //////////////////////////////////////////////////////////////////////////////////////
  128. // cooking Synths
  129. // run each one separately one after the other.
  130. // ACT I
  131. (
  132. ~act_I = Synth(\Granny,
  133. [
  134. // which sample should we use?
  135. \bufnum, ~granBfr.at(21), // "09 - PART II - Chorus.7.wav"
  136. // fade-in, fade-out
  137. \gainEnv, Env([0, 1, 1, 0], [1,320,40], \lin),
  138. \lpfEnv, Env([0.001, 1, 1, 0.001], [20,301,30], \exp),
  139. // LFOSpeed is the frequency of LF oscilator, then variation and min/max points
  140. \lpfLFOSpeed, 0.023, \lpfLFOSpeedVar, 0.041, \lpfLFOMin, 1000, \lpfLFOMax, 8000,
  141. \posLFOSpeed, 0.020, \posLFOSpeedVar, 0.089, \posLFOMin, 0.56, \posLFOMax, 0.92
  142. ]
  143. );
  144. )
  145. ( // ACT II --------------------------------------------------------------------------
  146. ~act_II = Synth(\Granny,
  147. [
  148. \bufnum, ~granBfr.at(43), // "23 - The Mother.6.wav"
  149. \gainEnv, Env([0, 1, 1, 0], [1,320,40], \lin),
  150. \lpfEnv, Env([0.001, 1, 1, 0.001], [19,301,30], \exp),
  151. \lpfLFOSpeed, 0.013, \lpfLFOSpeedVar, 0.041, \lpfLFOMin, 1000, \lpfLFOMax, 4000,
  152. \posLFOSpeed, 0.020, \posLFOSpeedVar, 0.089, \posLFOMin, 0.25, \posLFOMax, 0.90 ,
  153. ]
  154. );
  155. )
  156. ( // ACT IIb --------------------------------------------------------------------------
  157. ~act_IIb = Synth(\Granny,
  158. [
  159. \bufnum, ~granBfr.at(28), // "13 - Chorus Of The Self-Righteous.7.wav"
  160. \gainEnv, Env([0, 1, 1, 0], [1,320,40], \lin),
  161. \lpfEnv, Env([0.001, 1, 1, 0.001], [19,301,30], \exp),
  162. \lpfLFOSpeed, 0.013, \lpfLFOSpeedVar, 0.054, \lpfLFOMin, 1000, \lpfLFOMax, 2000,
  163. \posLFOSpeed, 0.057, \posLFOSpeedVar, 0.033, \posLFOMin, 0.1, \posLFOMax, 0.6,
  164. ]
  165. );
  166. )
  167. ( // ACT III (and ACT VII!) ------------------------------------------------------------
  168. ~act_III = Synth(\Granny,
  169. [
  170. \bufnum, ~granBfr.at(25), // "11 - Chorus Of The Persecutors And Persecuted.8.wav"
  171. \pitch, 0.95,
  172. \gainEnv, Env([0, 1, 1, 0], [1,320,40], \lin),
  173. \lpfEnv, Env([0.001, 1, 1, 0.001], [19,301,30], \exp),
  174. \lpfLFOSpeed, 0.063, \lpfLFOSpeedVar, 0.054, \lpfLFOMin, 1500, \lpfLFOMax, 6000,
  175. \posLFOSpeed, 0.037, \posLFOSpeedVar, 0.033, \posLFOMin, 0.1, \posLFOMax, 0.8,
  176. ]
  177. );
  178. )
  179. ( // ACT IV --------------------------------------------------------------------------
  180. ~act_IV = Synth(\Granny,
  181. [
  182. \bufnum, ~granBfr.at(45), // "26 - Part III - Chorus.1.wav"
  183. \gainEnv, Env([0, 1, 1, 0], [1,320,40], \lin),
  184. \lpfEnv, Env([0.001, 1, 1, 0.001], [19,301,30], \exp),
  185. \lpfLFOSpeed, 0.009, \lpfLFOSpeedVar, 0.054, \lpfLFOMin, 1000, \lpfLFOMax, 6000,
  186. \posLFOSpeed, 0.037, \posLFOSpeedVar, 0.033, \posLFOMin, 0.35, \posLFOMax, 0.95,
  187. ]
  188. );
  189. )
  190. ( // ACT V --------------------------------------------------------------------------
  191. ~act_V = Synth(\Granny,
  192. [
  193. \bufnum, ~granBfr.at(51), // "29 - PRELUDIUM - General Ensemble.7.wav"
  194. \gainEnv, Env([0, 1, 1, 0], [1,320,40], \lin),
  195. \lpfEnv, Env([0.001, 1, 1, 0.001], [19,301,30], \exp),
  196. \lpfLFOSpeed, 0.009, \lpfLFOSpeedVar, 0.054, \lpfLFOMin, 2000, \lpfLFOMax, 9000,
  197. \posLFOSpeed, 0.037, \posLFOSpeedVar, 0.033, \posLFOMin, 0.05, \posLFOMax, 0.55,
  198. ]
  199. );
  200. )
  201. ( // ACT VI --------------------------------------------------------------------------
  202. ~act_VI = Synth(\Granny,
  203. [
  204. \bufnum, ~granBfr.at(48), // "28 - Scena (Bass Solo & Chorus).8.wav"
  205. \gainEnv, Env([0, 1, 1, 0], [1,320,40], \lin),
  206. \lpfEnv, Env([0.001, 1, 1, 0.001], [19,301,30], \exp),
  207. \lpfLFOSpeed, 0.031, \lpfLFOSpeedVar, 0.054, \lpfLFOMin, 700, \lpfLFOMax, 1500,
  208. \posLFOSpeed, 0.037, \posLFOSpeedVar, 0.033, \posLFOMin, 0.15, \posLFOMax, 0.9,
  209. ]
  210. );
  211. )
  212. /////////////////////////////////////////////////////////////////////////////////////
  213. (
  214. // --------------------------------------------------------------------------
  215. // Track 02 from the album - "Chorus 1 (SC)"
  216. ~chorus1 = Synth(\Granny,
  217. [
  218. \bufnum, ~granBfr.at(3), // "01 - PART I - Chorus.12.wav"
  219. \lpfLFOSpeed, 0.021, \lpfLFOMin, 700, \lpfLFOMax, 6500,
  220. \posLFOSpeed, 0.017, \posLFOMin, 0.09, \posLFOMax, 0.91,
  221. \gain, 0.15,
  222. // fade-in, fade-out
  223. \gainEnv, Env([0, 1, 1, 0], [1,320,40], \lin),
  224. \lpfEnv, Env([0.001, 1, 1, 0.001], [19,301,30], \exp),
  225. \lpfLFOSpeedVar, 0.054, \posLFOSpeedVar, 0.033,
  226. ]
  227. );
  228. )
  229. (
  230. // --------------------------------------------------------------------------
  231. // Track 08 from the album - "Chorus 2 (SC)"
  232. ~number4 = Synth(\Granny,
  233. [
  234. \bufnum, ~granBfr.at(4), // "01 - PART I - Chorus.3.wav"
  235. \lpfLFOSpeed, 0.021, \lpfLFOMin, 700, \lpfLFOMax, 6500,
  236. \posLFOSpeed, 0.017, \posLFOMin, 0.09, \posLFOMax, 0.91,
  237. \gain, 0.15,
  238. // fade-in, fade-out
  239. \gainEnv, Env([0, 1, 1, 0], [1,320,40], \lin),
  240. \lpfEnv, Env([0.001, 1, 1, 0.001], [19,301,30], \exp),
  241. \lpfLFOSpeedVar, 0.054, \posLFOSpeedVar, 0.033,
  242. ]
  243. );
  244. )
  245. (
  246. // --------------------------------------------------------------------------
  247. // Track 10 from the album - "The Oppressed 2 (SC)"
  248. ~number12 = Synth(\Granny,
  249. [
  250. \bufnum, ~granBfr.at(12), // "05 - Chorus Of The Oppressed.11.wav"
  251. \lpfLFOSpeed, 0.015, \lpfLFOMin, 700, \lpfLFOMax, 5000,
  252. \posLFOSpeed, 0.01, \posLFOMin, 0.05, \posLFOMax, 0.95,
  253. \gain, 0.15, \pitch, 0.80,
  254. // fade-in, fade-out
  255. \gainEnv, Env([0, 1, 1, 0], [1,320,40], \lin),
  256. \lpfEnv, Env([0.001, 1, 1, 0.001], [15,301,30], \exp),
  257. \lpfLFOSpeedVar, 0.054, \posLFOSpeedVar, 0.033,
  258. ]
  259. );
  260. )