Source code for small two-tracker EP released in January 2022 on Bandcamp.
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.

158 lines
4.0 KiB

  1. /*
  2. algoforte #3 (220105b)
  3. code for first track of "algoforte01" - a two-tracker release on my
  4. bandcamp: https://music.lukaprincic.si or https://bandcamp.com/lukaprincic
  5. track 2 is a live performance of most the ideas in here with some changes
  6. that seem to be necessary for live coding performance. :/
  7. to use this code you need to be able to send midi out to either virtual
  8. instrument that plays a grand piano (a sampler or similar). i personally
  9. used Salamander Grand Piano SFZ loaded into Renoise.
  10. you can also use disklavier if you have one handy nearby.
  11. by starting MIDIClient.init (and waiting for a second or two)
  12. and then m=MIDIOut(0) a midi output/input is created for SC.
  13. the midi out from SC must go into midi input of the sampler/piano,
  14. use test Pbindef to test. midichannel on sampler/piano: 1 (in SC: 0)
  15. route audio output from piano back to SC and disconnect it from
  16. main output (speakers). this is easily done using JACK.
  17. requirement for this patch is also DEINDUGens which include JPverb
  18. */
  19. // helpers:
  20. s.boot
  21. s.meter
  22. s.plotTree
  23. // init midi
  24. MIDIClient.init(1,1);
  25. // create output on channel 1
  26. m = MIDIOut(0)
  27. // connect.
  28. m.connect
  29. // test
  30. Pbindef(\testmidi, \type, \midi, \midicmd, \noteOn, \midiout, m, \chan, 0, \amp, 0.5).play
  31. Pbindef(\testmidi).stop
  32. // processing input from piano
  33. (
  34. Ndef(\inDSPout, {
  35. var snd, flt, rev, dly;
  36. snd = SoundIn.ar([0,1]);
  37. snd = snd * LFPulse.kr(LFNoise1.kr(1/5).range(3,20), 0,
  38. 0.5).range(LFNoise1.kr(1/10).range(0.6,1),1).lag(0.00001);
  39. flt = BPF.ar(snd, LFNoise1.kr([1/4,1/5]).exprange(500,5000), 0.3, 2); // ??
  40. dly = CombL.ar(flt + snd, 1, SinOsc.ar([1/60, 1/70]).range(1, 1.2), 10, 0.3 * LFNoise1.kr(1/10).range(0.4,1) , snd);
  41. rev = JPverb.ar(flt + snd, 6, 0, 20) * LFNoise1.kr(1/10).range(0.4,1);
  42. snd = snd + dly + rev * 0.8;
  43. Limiter.ar(snd, 0.8);
  44. })
  45. )
  46. Ndef(\inDSPout).fadeTime = 4
  47. Ndef(\inDSPout).play(fadeTime:5)
  48. // when needed:
  49. Ndef(\inDSPout).end(30)
  50. Ndef(\inDSPout).stop
  51. (
  52. Pbindef(\p220105b, \type, \midi, \midicmd, \noteOn, \midiout, m, \chan, 0,
  53. \dur, Pseq([
  54. Pn(1/2, 50),
  55. Pseq([1, 1/2, Pn(1/4,4), 2], 20), // 7*20
  56. Pseq([
  57. 1,
  58. 1/2,
  59. Pn(1/4, 2),
  60. Prand([2, 1/2, Pn(1/3,3)]),
  61. Pwrand([1/2, Pn(1/8,4)], [0.9, 0.1]),
  62. Pwrand([1/2, 6,], [0.9, 0.1]),
  63. ], 10 * 5 ),
  64. Pn(1/2, 60)
  65. ])
  66. * Pwhite(0.99,1.2),
  67. \amp, Pseq([0.6, Pwhite(0.2,0.5,3), 0.5, Pwhite(0.2,0.5,2)], inf) * Pwhite(1, 1.1),
  68. \degree, Place([0, 0, 2, 0, [2, 3, 5]],inf), // cycle of 5
  69. \scale, Scale.minor,
  70. \mtranspose, Pseq([
  71. 0,
  72. 5,
  73. 7,
  74. [2,5],
  75. [3,6],
  76. [0,2]
  77. [0,5,7],
  78. [0,5,9],
  79. [3,5,7,10],
  80. [2,5,9,11],
  81. [0,4,7,11] + 7,
  82. [5,4,7,11],
  83. [0,4,-7]
  84. ],inf) + Pseq([ Pn(0, 50 + (7*20)), Pseq([Pn(0,50), Pn(3,20), Pn(-2,20)], 3)], inf), // (50+140+(3x90))
  85. \ctranspose,
  86. Pseq([
  87. Pn(0, 50+140),
  88. Pseq([Pn(0,60), Pn(5, 60), Pn(0,60), Pn(7,60)]), // (4*60+50+140)
  89. Pn(0,inf) //
  90. ])
  91. + Pseq([ Pn(0,300), Pwrand([0, 5, 7], [0.9, 0.05, 0.05], 100), Pn(0, inf)]),
  92. \octave, Pwrand([5,[5,6],[4,6]], [0.8,0.1,0.1], inf),
  93. \legato, Pwhite(0.5,4)
  94. ).play
  95. )
  96. // allocate new buffer
  97. b = Buffer.alloc(s, s.sampleRate*10, 1)
  98. // start recording into buffer via 'in'
  99. Ndef(\recbuf, {var sn=\in.ar(0!2); RecordBuf.ar(sn[0], b)})
  100. // plug output from inDSPout to in of \recbuf
  101. Ndef(\recbuf) <<>.in Ndef(\inDSPout)
  102. // is there something being recorded in a buffer?
  103. b.plot
  104. // when needed - stop recording to a buffer
  105. Ndef(\recbuf).clear
  106. // GRANULATE THE CONTENTS OF THE BUFFER
  107. (
  108. Ndef(\gran, {
  109. var snd = GrainBuf.ar(2,
  110. trigger: Impulse.ar(LFNoise1.kr(1/10!3).exprange(1, 80) * LFNoise0.ar(100).range(0.7,1.1)),
  111. dur: LFNoise1.ar(1).range(0.08,0.1),
  112. sndbuf: b,
  113. rate:[1,1/2,2], pos:LFNoise1.kr(1/20!3).range(0,1),
  114. pan: LFNoise0.ar(100).range(-1,1)
  115. );
  116. snd = LPF.ar(snd, LFNoise1.kr(1/10!3).exprange(500,10000));
  117. snd = Mix(snd);
  118. snd = JPverb.ar(snd, LFNoise1.kr(1/10!2).range(1,10)) + snd;
  119. Limiter.ar(Mix(snd), 0.8) * Env.circle([0.01,0.3,0.01],90,\cub).kr * 0.5;
  120. })
  121. )
  122. Ndef(\gran).fadeTime = 5
  123. Ndef(\gran).play
  124. Ndef(\gran).end(30) // fadeout
  125. Ndef(\gran).stop // stop immediately (send note offs)