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.

254 lines
10 KiB

  1. (
  2. /* *************************************************************************
  3. _____ ____ __. /\ ____________________ _____
  4. / | || |/ _| / / \______ \______ \/ \
  5. / | || < / / | | _/| ___/ \ / \
  6. / ^ / | \ / / | | \| | / Y \
  7. \____ ||____|__ \ / / |______ /|____| \____|__ /
  8. |__| \/ \/ \/ \/
  9. __________________ .____ ________ __
  10. / _____/\_ ___ \| | \_____ \_______| | __
  11. \_____ \ / \ \/| | / | \_ __ \ |/ /
  12. / \\ \___| |___/ | \ | \/ <
  13. /_______ / \______ /_______ \_______ /__| |__|_ \
  14. \/ \/ \/ \/ \/
  15. v150403
  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. 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. // effects and master out midi control
  50. MIDIdef.cc(\midifXcombWet, { | val | ~fX.set(\combWet, val/200); }, 60 ); // comb filter WET
  51. MIDIdef.cc(\midifXlpfCutoff, { | val |
  52. var cutoff; cutoff = (exp(val/12)+50).asInt.min(20000);
  53. ~fX.set(\lpfCutoff, cutoff); }, 61 ); // LPF cutoff freq
  54. MIDIdef.cc(\midifXreverbWet, { | val | ~fX.set(\reverbWet, val/300); }, 62 ); // Reverb WET
  55. MIDIdef.cc(\midifXgain, { | val | ~fX.set(\gain, val/127); }, 63 ); // MASTER OUT
  56. /* *************************************************************************************
  57. SCHEDULE SYNTHS USING EVENTS
  58. **************************** */
  59. v = Main.elapsedTime.ceil;
  60. t = TempoClock(1, 0, v);
  61. t.schedAbs(0, {
  62. ~fX = (instrument: \fX).play;
  63. ~kindaBass = (instrument: \kindaBass).play;
  64. ~wierdBleep = (instrument: \wierdBleep).play;
  65. ~sine666 = (instrument: \sine666).play;
  66. ~lFPar1 = (instrument: \LFPar1).play;
  67. ~lowCub = (instrument: \lowCub).play;
  68. ~lowCub2 = (instrument: \lowCub2).play;
  69. ~midCub = (instrument: \midCub).play;
  70. ~hiCub = (instrument: \hiCub).play;
  71. ~addCub = (instrument: \addCub).play;
  72. ~sine365 = (instrument: \sine365).play;
  73. ~sine65 = (instrument: \sine65).play;
  74. ~sin800 = (instrument: \sin800).play;
  75. ~sin5800 = (instrument: \sin5800).play;
  76. ~cub820 = (instrument: \cub820).play;
  77. ~lfPar7820 = (instrument: \lfPar7820).play;
  78. ~white1 = (instrument: \white1).play;
  79. ~white2 = (instrument: \white2).play;
  80. ~white3 = (instrument: \white3).play;
  81. ~white4 = (instrument: \white4).play;
  82. ~lfTri = (instrument: \lfTri).play;
  83. postln(v);
  84. });
  85. // HERE BE SOME FUNKY VARIABLES ///////////////////////////////////////
  86. // SCALES! //
  87. ~aSc = Scale.minorPentatonic; // define scale type
  88. ~freqTrig = { Impulse.kr(rrand(0.01,0.05)); }; // how fast the note changes
  89. ~freqOff = {rrand(0.98, 1.02);}; // detune a bit
  90. // define one var for each octave for use in SynthDefs
  91. ~freqVar3 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 3) ).midicps * ~freqOff };
  92. ~freqVar4 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 4) ).midicps * ~freqOff };
  93. ~freqVar5 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 5) ).midicps * ~freqOff };
  94. ~freqVar6 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 6) ).midicps * ~freqOff };
  95. ~freqVar7 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 7) ).midicps * ~freqOff };
  96. ~freqVar8 = { (Demand.kr(~freqTrig, 0, (Dxrand(~aSc.semitones, inf))) + (12 * 8) ).midicps * ~freqOff };
  97. ~chanExpan = [1,1]; // multi channel expansion (just stereo here)
  98. ~bpm = 1; // bpm, for now constant, it could drift...
  99. /* *************************************************************************************
  100. DEFINE SYNTHS AND ADD TO SERVER
  101. ******************************* */
  102. SynthDef(\kindaBass, { | out=0, gain=0 |
  103. out = SinOsc.ar( ((LFSaw.kr(-0.05,1) + 1) * 100 + 40 ), LFTri.kr(40,0,1),
  104. LFSaw.kr(1.5 * ~bpm) ) * 0.5 * ~chanExpan * gain;
  105. OffsetOut.ar(0, out); }).add;
  106. SynthDef(\wierdBleep, { | out=0, gain=0 |
  107. out = LFPulse.ar(~freqVar3, 0, 0.5, LFPulse.kr((1/2) * ~bpm, 0.5, 0.03, 0.05))
  108. * ~chanExpan * gain;
  109. OffsetOut.ar(0, out); }).add;
  110. SynthDef(\sine666, { | out=0, gain=0 |
  111. out = SinOsc.ar(~freqVar4, 0, LFPulse.kr((2/3) * ~bpm, 0.5, 0.3) * 0.3)
  112. * ~chanExpan * gain;
  113. OffsetOut.ar(0, out); }).add;
  114. SynthDef(\LFPar1, { | out=0, gain=0 |
  115. out = LFPar.ar(~freqVar4, 0, LFPulse.kr((1/2) * ~bpm, 0.5,0.2) * 0.3)
  116. * ~chanExpan * gain;
  117. OffsetOut.ar(0, out); }).add;
  118. SynthDef(\lowCub, { | out=0, gain=0 |
  119. out = LFCub.ar(~freqVar3, 0, LFPulse.kr((1/2) * ~bpm, 0.74,0.2) * 0.3)
  120. * ~chanExpan * gain;
  121. OffsetOut.ar(0, out); }).add;
  122. SynthDef(\lowCub2, { | out=0, gain=0 |
  123. out = LFCub.ar(~freqVar3, 0, LFPulse.kr((4/3) * ~bpm, 0.74,0.2) * 0.3)
  124. * ~chanExpan * gain;
  125. OffsetOut.ar(0, out); }).add;
  126. SynthDef(\midCub, { | out=0, gain=0 |
  127. out = LFCub.ar(~freqVar5, 0, LFPulse.kr((1/2) * ~bpm, 0.74,0.1) * 0.2)
  128. * ~chanExpan * gain;
  129. OffsetOut.ar(0, out); }).add;
  130. SynthDef(\hiCub, { | out=0, gain=0 |
  131. 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)
  132. * ~chanExpan * gain;
  133. OffsetOut.ar(0, out); }).add;
  134. SynthDef(\addCub, { | out=0, gain=0 |
  135. 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)
  136. * ~chanExpan * gain;
  137. OffsetOut.ar(0, out); }).add;
  138. SynthDef(\sine65, { | out=0, gain=0 |
  139. out = SinOsc.ar(~freqVar3, 0, LFPulse.kr( (1) * ~bpm, 0, 0.1)*0.3)
  140. * ~chanExpan * gain;
  141. OffsetOut.ar(0, out); }).add;
  142. SynthDef(\sine365, { | out=0, gain=0 |
  143. out = SinOsc.ar(~freqVar4, 0, LFPulse.kr( (4/3) * ~bpm, 0, 0.1)*0.3)
  144. * ~chanExpan * gain;
  145. OffsetOut.ar(0, out); }).add;
  146. SynthDef(\sin800, { | out=0, gain=0 |
  147. out = SinOsc.ar(~freqVar5, 0, LFPulse.kr(2 * ~bpm,0,0.1)*0.1)
  148. * ~chanExpan * gain;
  149. OffsetOut.ar(0, out); }).add;
  150. SynthDef(\sin5800, { | out=0, gain=0 |
  151. 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)
  152. * ~chanExpan * gain;
  153. OffsetOut.ar(0, out); }).add;
  154. SynthDef(\cub820, { | out=0, gain=0 |
  155. out = LFCub.ar(~freqVar5, 0, LFPulse.kr( (5/3) * ~bpm, 0, 0.1)*0.1)
  156. * ~chanExpan * gain;
  157. OffsetOut.ar(0, out); }).add;
  158. SynthDef(\lfPar7820, { | out=0, gain=0 |
  159. out = LFPar.ar(~freqVar8, 0, LFPulse.kr( (5/3) * ~bpm, 0, 0.03)*0.1)
  160. * ~chanExpan * gain;
  161. OffsetOut.ar(0, out); }).add;
  162. SynthDef(\white1, { | out=0, gain=0 |
  163. out = WhiteNoise.ar( LFPulse.kr(2 * ~bpm,0.5,0.001,1) )/2
  164. * ~chanExpan * gain;
  165. OffsetOut.ar(0, out); }).add;
  166. SynthDef(\white2, { | out=0, gain=0 |
  167. out = WhiteNoise.ar( LFPulse.kr(1 * ~bpm,0.5,0.001,1) )/2
  168. * ~chanExpan * gain;
  169. OffsetOut.ar(0, out); }).add;
  170. SynthDef(\white3, { | out=0, gain=0 |
  171. out = WhiteNoise.ar( LFPulse.kr( (5/3) * ~bpm,0.5,0.001,1) )/4
  172. * ~chanExpan * gain;
  173. OffsetOut.ar(0, out); }).add;
  174. SynthDef(\white4, { | out=0, gain=0 |
  175. out = WhiteNoise.ar( LFPulse.kr( (4/3) * ~bpm,0.5,0.001,1) )/4
  176. * ~chanExpan * gain;
  177. OffsetOut.ar(0, out); }).add;
  178. SynthDef(\lfTri, { | out=0, gain=0 |
  179. out = LFTri.ar(~freqVar4, 0, LFPulse.kr(0.5 * ~bpm,0.25,0.01)*0.3)
  180. * ~chanExpan * gain;
  181. OffsetOut.ar(0, out); }).add;
  182. // effects!
  183. SynthDef(\fX, { | in=0, out=0, reverbWet=0, combWet=0, lpfCutoff=20000, gain=0.4 |
  184. var input, output;
  185. input = In.ar(in, 2);
  186. output = CombC.ar(in:input, // comb filter
  187. maxdelaytime:0.1,
  188. delaytime:SinOsc.kr(
  189. freq:rrand(0.01,0.001),
  190. phase:0.25,
  191. mul:0.03,
  192. add:0.05 ),
  193. mul:combWet,
  194. add:input);
  195. output = BLowPass4.ar(in:output, freq:lpfCutoff, rq:1); // low pass filter
  196. output = Limiter.ar((output*0.9), 0.95, 0.01); // limiter
  197. output = output + FreeVerb.ar(output*reverbWet, 1, rrand(0.5,1), 0.1); // reverb
  198. output = output * gain; // gain control
  199. ReplaceOut.ar(out, output); // replace the audio on the bus!
  200. }).add;
  201. /* ************************************************************************************************* */
  202. // END
  203. )