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.

273 lines
11 KiB

7 years ago
  1. (
  2. /* *************************************************************************
  3. _____ ____ __. /\ ____________________ _____
  4. / | || |/ _| / / \______ \______ \/ \
  5. / | || < / / | | _/| ___/ \ / \
  6. / ^ / | \ / / | | \| | / Y \
  7. \____ ||____|__ \ / / |______ /|____| \____|__ /
  8. |__| \/ \/ \/ \/
  9. __________________ .____ ________ __
  10. / _____/\_ ___ \| | \_____ \_______| | __
  11. \_____ \ / \ \/| | / | \_ __ \ |/ /
  12. / \\ \___| |___/ | \ | \/ <
  13. /_______ / \______ /_______ \_______ /__| |__|_ \
  14. \/ \/ \/ \/ \/
  15. v150409
  16. "4K/BPM SCLOrk" for Santa Clara University Laptop Orchestra
  17. by Luka Prinčič / Nova deViator <nova@deviator.si>
  18. thanks to Bruno Ruviaro
  19. adapted from 4K/BPM Sonoretum patch, released and
  20. installed at Sonoretum project / Kapelica Gallery, Ljubljana
  21. thanks to Marko Košnik, Sandra Sajovic and Jurij Krpan
  22. released under GNU GPL. feel free to copy, reuse, remix,
  23. provided that you share under same conditions: GNU GPL.
  24. ***************************************************************************** */
  25. /* *************************************************************************************
  26. MIDI CONTROLS
  27. *************
  28. GENERATORS' GAINS: midi */
  29. MIDIdef.cc(\midilfTri, { | val | ~lfTri.set(\gain, val/127); }, 0 );
  30. MIDIdef.cc(\midikindaBass, { | val | ~kindaBass.set(\gain, val/127); }, 1 );
  31. MIDIdef.cc(\midiwierdBleep, { | val | ~wierdBleep.set(\gain, val/127); }, 2 );
  32. MIDIdef.cc(\midisine666, { | val | ~sine666.set(\gain, val/127); }, 3 );
  33. MIDIdef.cc(\midilFPar1, { | val | ~lFPar1.set(\gain, val/127); }, 4 );
  34. MIDIdef.cc(\midilowCub, { | val | ~lowCub.set(\gain, val/127); }, 5 );
  35. MIDIdef.cc(\midimidCub, { | val | ~midCub.set(\gain, val/127); }, 6 );
  36. MIDIdef.cc(\midihiCub, { | val | ~hiCub.set(\gain, val/127); }, 7 );
  37. MIDIdef.cc(\midiaddCub, { | val | ~addCub.set(\gain, val/127); }, 8 );
  38. MIDIdef.cc(\midisine356, { | val | ~sine365.set(\gain, val/127); }, 9 );
  39. MIDIdef.cc(\midisin800, { | val | ~sin800.set(\gain, val/127); }, 10 );
  40. MIDIdef.cc(\midisin5800, { | val | ~sin5800.set(\gain, val/127); }, 11 );
  41. MIDIdef.cc(\midicub820, { | val | ~cub820.set(\gain, val/127); }, 12 );
  42. MIDIdef.cc(\midilfPar7820, { | val | ~lfPar7820.set(\gain, val/127); }, 13 );
  43. MIDIdef.cc(\midiwhite1, { | val | ~white1.set(\gain, val/127); }, 14 );
  44. MIDIdef.cc(\midiwhite2, { | val | ~white2.set(\gain, val/127); }, 15 );
  45. MIDIdef.cc(\midiwhite3, { | val | ~white3.set(\gain, val/127); }, 16 );
  46. MIDIdef.cc(\midiwhite4, { | val | ~white4.set(\gain, val/127); }, 17 );
  47. MIDIdef.cc(\midisine56, { | val | ~sine65.set(\gain, val/127); }, 18 );
  48. MIDIdef.cc(\midilowCub2, { | val | ~lowCub2.set(\gain, val/127); }, 19 );
  49. MIDIdef.cc(\midiwhite5, { | val | ~white5.set(\gain, val/127); }, 20 );
  50. MIDIdef.cc(\midibrown1, { | val | ~brown1.set(\gain, val/127); }, 21 );
  51. // ------------------------------------------------------------------------------- //
  52. // effects and master out midi control
  53. MIDIdef.cc(\midifXcombWet, { | val | ~fX.set(\combWet, val/300); }, 60 ); // comb filter WET
  54. MIDIdef.cc(\midifXlpfCutoff, { | val |
  55. var cutoff; cutoff = (exp(val/12)+50).asInt.min(20000);
  56. ~fX.set(\lpfCutoff, cutoff); }, 61 ); // LPF cutoff freq
  57. MIDIdef.cc(\midifXreverbWet, { | val | ~fX.set(\reverbWet, val/300); }, 62 ); // Reverb WET
  58. MIDIdef.cc(\midifXgain, { | val | ~fX.set(\gain, val/127); }, 63 ); // MASTER OUT
  59. //s.makeGui;
  60. /* *************************************************************************************
  61. SCHEDULE SYNTHS USING EVENTS
  62. **************************** */
  63. v = Main.elapsedTime.ceil;
  64. t = TempoClock(1, 0, v);
  65. t.schedAbs(0, {
  66. ~fX = (instrument: \fX).play;
  67. ~kindaBass = (instrument: \kindaBass).play;
  68. ~wierdBleep = (instrument: \wierdBleep).play;
  69. ~sine666 = (instrument: \sine666).play;
  70. ~lFPar1 = (instrument: \LFPar1).play;
  71. ~lowCub = (instrument: \lowCub).play;
  72. ~lowCub2 = (instrument: \lowCub2).play;
  73. ~midCub = (instrument: \midCub).play;
  74. ~hiCub = (instrument: \hiCub).play;
  75. ~addCub = (instrument: \addCub).play;
  76. ~sine365 = (instrument: \sine365).play;
  77. ~sine65 = (instrument: \sine65).play;
  78. ~sin800 = (instrument: \sin800).play;
  79. ~sin5800 = (instrument: \sin5800).play;
  80. ~cub820 = (instrument: \cub820).play;
  81. ~lfPar7820 = (instrument: \lfPar7820).play;
  82. ~white1 = (instrument: \white1).play;
  83. ~white2 = (instrument: \white2).play;
  84. ~white3 = (instrument: \white3).play;
  85. ~white4 = (instrument: \white4).play;
  86. ~lfTri = (instrument: \lfTri).play;
  87. ~white5 = (instrument: \white5).play;
  88. ~brown1 = (instrument: \brown1).play;
  89. postln(v);
  90. });
  91. // HERE BE SOME FUNKY VARIABLES ///////////////////////////////////////
  92. // SCALES! //
  93. ~aSc = Scale.minorPentatonic; // define scale type
  94. ~freqTrig = { Impulse.kr(rrand(0.01,0.05)); }; // how fast the note changes
  95. ~freqOff = {rrand(0.98, 1.02);}; // detune a bit
  96. // define one var for each octave for use in SynthDefs
  97. ~freqVar3 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 3) ).midicps * ~freqOff };
  98. ~freqVar4 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 4) ).midicps * ~freqOff };
  99. ~freqVar5 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 5) ).midicps * ~freqOff };
  100. ~freqVar6 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 6) ).midicps * ~freqOff };
  101. ~freqVar7 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 7) ).midicps * ~freqOff };
  102. ~freqVar8 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 8) ).midicps * ~freqOff };
  103. ~chanExpan = [1,1]; // multi channel expansion (just stereo here)
  104. ~bpm = 1; // bpm, for now constant, it could drift...
  105. /* *************************************************************************************
  106. DEFINE SYNTHS AND ADD TO SERVER
  107. ******************************* */
  108. SynthDef(\kindaBass, { | out=0, gain=0 |
  109. out = SinOsc.ar( ((LFSaw.kr(-0.05,1) + 1) * 100 + 40 ), LFTri.kr(40,0,1),
  110. LFSaw.kr(1.5 * ~bpm) ) * 0.5 * ~chanExpan * gain;
  111. OffsetOut.ar(0, out); }).add;
  112. SynthDef(\wierdBleep, { | out=0, gain=0 |
  113. out = LFPulse.ar(~freqVar3, 0, 0.5, LFPulse.kr((1/2) * ~bpm, 0.5, 0.03, 0.05))
  114. * ~chanExpan * gain;
  115. OffsetOut.ar(0, out); }).add;
  116. SynthDef(\sine666, { | out=0, gain=0 |
  117. out = SinOsc.ar(~freqVar4, 0, LFPulse.kr((2/3) * ~bpm, 0.5, 0.3) * 0.3)
  118. * ~chanExpan * gain;
  119. OffsetOut.ar(0, out); }).add;
  120. SynthDef(\LFPar1, { | out=0, gain=0 |
  121. out = LFPar.ar(~freqVar4, 0, LFPulse.kr((1/2) * ~bpm, 0.5,0.2) * 0.3)
  122. * ~chanExpan * gain;
  123. OffsetOut.ar(0, out); }).add;
  124. SynthDef(\lowCub, { | out=0, gain=0 |
  125. out = LFCub.ar(~freqVar3, 0, LFPulse.kr((1/2) * ~bpm, 0.74,0.2) * 0.3)
  126. * ~chanExpan * gain;
  127. OffsetOut.ar(0, out); }).add;
  128. SynthDef(\lowCub2, { | out=0, gain=0 |
  129. out = LFCub.ar(~freqVar3, 0, LFPulse.kr((4/3) * ~bpm, 0.74,0.2) * 0.3)
  130. * ~chanExpan * gain;
  131. OffsetOut.ar(0, out); }).add;
  132. SynthDef(\midCub, { | out=0, gain=0 |
  133. out = LFCub.ar(~freqVar5, 0, LFPulse.kr((1/2) * ~bpm, 0.74,0.1) * 0.2)
  134. * ~chanExpan * gain;
  135. OffsetOut.ar(0, out); }).add;
  136. SynthDef(\hiCub, { | out=0, gain=0 |
  137. out = LFCub.ar(~freqVar7, 0, LFPulse.kr((4/3) * ~bpm, 0.76, SinOsc.kr(rrand(0.01,0.001),mul:0.05, add:0.055)) * 0.1)
  138. * ~chanExpan * gain;
  139. OffsetOut.ar(0, out); }).add;
  140. SynthDef(\addCub, { | out=0, gain=0 |
  141. out = LFCub.ar(~freqVar7, 0, LFPulse.kr((5/3) * ~bpm, 0.24, SinOsc.kr(rrand(0.01,0.001),mul:0.05, add:0.055) )*0.1)
  142. * ~chanExpan * gain;
  143. OffsetOut.ar(0, out); }).add;
  144. SynthDef(\sine65, { | out=0, gain=0 |
  145. out = SinOsc.ar(~freqVar3, 0, LFPulse.kr( (1) * ~bpm, 0, 0.1)*0.3)
  146. * ~chanExpan * gain;
  147. OffsetOut.ar(0, out); }).add;
  148. SynthDef(\sine365, { | out=0, gain=0 |
  149. out = SinOsc.ar(~freqVar4, 0, LFPulse.kr( (4/3) * ~bpm, 0, 0.1)*0.3)
  150. * ~chanExpan * gain;
  151. OffsetOut.ar(0, out); }).add;
  152. SynthDef(\sin800, { | out=0, gain=0 |
  153. out = SinOsc.ar(~freqVar5, 0, LFPulse.kr(2 * ~bpm,0,0.1)*0.1)
  154. * ~chanExpan * gain;
  155. OffsetOut.ar(0, out); }).add;
  156. SynthDef(\sin5800, { | out=0, gain=0 |
  157. out = SinOsc.ar(~freqVar8, 0, LFPulse.kr(2 * ~bpm,0, SinOsc.kr(rrand(0.01,0.001),mul:0.05, add:0.055))*0.1)
  158. * ~chanExpan * gain;
  159. OffsetOut.ar(0, out); }).add;
  160. SynthDef(\cub820, { | out=0, gain=0 |
  161. out = LFCub.ar(~freqVar5, 0, LFPulse.kr( (5/3) * ~bpm, 0, 0.1)*0.1)
  162. * ~chanExpan * gain;
  163. OffsetOut.ar(0, out); }).add;
  164. SynthDef(\lfPar7820, { | out=0, gain=0 |
  165. out = LFPar.ar(~freqVar8, 0, LFPulse.kr( (5/3) * ~bpm, 0, 0.03)*0.1)
  166. * ~chanExpan * gain;
  167. OffsetOut.ar(0, out); }).add;
  168. SynthDef(\white1, { | out=0, gain=0 |
  169. out = WhiteNoise.ar( LFPulse.kr(2 * ~bpm,0.5,0.001,1) )/2
  170. * ~chanExpan * gain;
  171. OffsetOut.ar(0, out); }).add;
  172. SynthDef(\white2, { | out=0, gain=0 |
  173. out = WhiteNoise.ar( LFPulse.kr(1 * ~bpm,0.5,0.001,1) )/2
  174. * ~chanExpan * gain;
  175. OffsetOut.ar(0, out); }).add;
  176. SynthDef(\white3, { | out=0, gain=0 |
  177. out = WhiteNoise.ar( LFPulse.kr( (5/3) * ~bpm,0.5,0.001,1) )/4
  178. * ~chanExpan * gain;
  179. OffsetOut.ar(0, out); }).add;
  180. SynthDef(\white4, { | out=0, gain=0 |
  181. out = WhiteNoise.ar( LFPulse.kr( (4/3) * ~bpm,0.5,0.001,1) )/4
  182. * ~chanExpan * gain;
  183. OffsetOut.ar(0, out); }).add;
  184. SynthDef(\lfTri, { | out=0, gain=0 |
  185. out = LFTri.ar(~freqVar4, 0, LFPulse.kr(0.5 * ~bpm,0.25,0.01)*0.3)
  186. * ~chanExpan * gain;
  187. OffsetOut.ar(0, out); }).add;
  188. SynthDef(\white5, { | out=0, gain=0 |
  189. out = RHPF.ar(WhiteNoise.ar( LFPulse.kr( (1/8) * ~bpm,0.5,0.1,1) ),4000)*0.05
  190. * ~chanExpan * gain;
  191. OffsetOut.ar(0, out); }).add;
  192. SynthDef(\brown1, { | out=0, gain=0 |
  193. out = RLPF.ar(BrownNoise.ar( LFPulse.kr( (1/9) * ~bpm,0.5,0.05,1) ),8000)*0.1
  194. * ~chanExpan * gain;
  195. OffsetOut.ar(0, out); }).add;
  196. // effects!
  197. SynthDef(\fX, { | in=0, out=0, reverbWet=0, combWet=0, lpfCutoff=20000, gain=0.4 |
  198. var input, output;
  199. input = In.ar(in, 2);
  200. output = CombC.ar(in:input, // comb filter
  201. maxdelaytime:0.1,
  202. delaytime:SinOsc.kr(
  203. freq:rrand(0.01,0.001),
  204. phase:0.25,
  205. mul:0.03,
  206. add:0.05 ),
  207. mul:combWet,
  208. add:input);
  209. output = BLowPass4.ar(in:output, freq:lpfCutoff, rq:1); // low pass filter
  210. output = Limiter.ar((output*0.9), 0.95, 0.01); // limiter
  211. output = output + FreeVerb.ar(output*reverbWet, 1, rrand(0.5,1), 0.1); // reverb
  212. output = output * gain; // gain control
  213. output = [output,output,output,output]; // send it to 4 channels
  214. ReplaceOut.ar(out, output); // replace the audio on the bus!
  215. //Out.ar(2, out);
  216. }).add;
  217. /* ************************************************************************************************* */
  218. // END
  219. )