// title: Generative jazz // author: Devi Skanadze // description: // download drum loop: // // https://www.dropbox.com/s/6yyrm7ivwqmxbdi/jloop2.wav?dl=0 // code: // Morning jazz2 by Notgoodenough ( ~buff1 = Buffer.read(s, "jloop2.wav".resolveRelative); ~mthue = {arg i, base, mul;(i * mul).asDigits(base).sum}; ~eu = {arg len, hits; var seq = Array.newClear(); for(0, len - 1, {arg i;seq = seq.add((i * hits % len) < hits)}); seq}; ~bpm = 95; ) ( SynthDef(\bell, { arg freq, amount = 100, ratio = 2, release = 0.5; var snd, mod, env; mod = SinOsc.ar(freq.midicps * 3, mul: amount); env = EnvGen.kr(Env.linen(0.02, 0.1, release, 0.1), doneAction: 2); snd = SinOsc.ar(freq.midicps + mod , mul: env); Out.ar(0, snd * 0.5 ! 2); }).add; SynthDef(\slicer, { arg buff = ~buff1, pos = 0, len = 2; var snd, dur, chunk; dur = 15 / ~bpm; chunk = BufFrames.kr(buff) / 16; snd = BufRd.ar(2, buff, Line.ar(pos * chunk, (pos * chunk) + (chunk * len), dur * len, doneAction: 2)); Out.ar(0, snd); }).add; ) ( var count = 0, rd = 0, oct = 0, pitch = 0, scale = Scale.minorPentatonic.degrees, bang = ~eu.value(28,19), count2 = 0, rd2 = 0, oct2 = 0, pitch2, scale2 = Scale.ritusen.degrees, bang2 = ~eu.value(9,4), len = 0, shift, cnt = 0, shread = 0, sh = [0,5,-3,3,7]; ~t = Task({ inf.do({ cnt = cnt + 1 % 102; if(cnt == 101, {shread = shread + 1 % sh.size}); pitch = ~mthue.value(count,16,8); if(pitch > scale.size, {oct = 12}, {oct = 0}); pitch2 = ~mthue.value(count2,13,3); if(pitch2 > scale2.size, {oct2 = 12}, {oct = 0}); rd = rd + 1 % 28; rd2 = rd2 + 1 % 9; if(bang[rd], {count = count + 1 % 18; Synth(\bell, [\freq, scale[pitch % scale.size] + 60 + oct + sh[shread], \amount, rrand(100,500), \release, rrand(0.5,1.5), \ratio, rrand(3,12); ]); }); if(bang2[rd2], {count2 = count2 + 1 % 34; Synth(\bell, [\freq, scale2[pitch2 % scale2.size] + 60 + oct2 + sh[shread], \amount, rrand(100,500), \release, rrand(0.5,1.5), \ratio, rrand(3,12); ]); }); (15 / ~bpm).wait; // 16th }); }).play; ~beat = Task({ inf.do({ len = rrand(4,6); Synth(\slicer, [\pos, rrand(0,15), \len, len]); (15 / ~bpm * len).wait; }); }).play; ) ~t.stop; ~beat.stop;