{
   "description" : "A short experiment I did with Pdefs and Pwrand to make a trance-like track focuses on ever-chaning rhythms. I'll post an updated version tomorrow.",
   "ancestor_list" : [],
   "author" : "rumush",
   "name" : "Algorithmic Beats",
   "code" : "// Rumush\r\n// Facebook: https://www.facebook.com/rumushproduction\r\n// SoundCloud: https://soundcloud.com/rumushproduction\r\n// YouTube: https://www.youtube.com/channel/UCs_Cn1R4iFrYOyc8liFucSQ\r\n// Blog: https://mycelialcordsblog.wordpress.com/\r\n// GitHub: https://github.com/RumushMycelialCords\r\n\r\n(// SynthDef and Ndef\r\n~tp = 145/60; // 145 BPM\r\nSynthDef(\\sin, {arg freq=50, lw=0, index=1000, lpF=20000, hpF=40, mix=0.75, dur, amp=0.125, pan=0, out=0;\r\n\tvar env = {arg dr, ml; Decay.ar(Impulse.ar(0),dr,ml)};\r\n\tvar src1 = SinOsc.ar(\r\n\t\tfreq+env.(dur*Rand(0.05,0.125),freq*(IRand(4,16))),2pi,\r\n\t\tenv.(dur,amp*mix)\r\n\t);\r\n\tvar src2 = SinOscFB.ar(\r\n\t\tfreq+(src1*index),Rand(lw,2),env.(dur*Rand(0.05,1),amp*(1-mix))\r\n\t);\r\n\tvar src = Pan2.ar(src1+src2,pan);\r\n\tvar free = DetectSilence.ar(src,doneAction:2);\r\n\tsrc = LPF.ar(src,lpF);\r\n\tsrc = HPF.ar(src,hpF);\r\n\r\n\tOut.ar(out,Compander.ar(src,src,0.25,1,1/4,0.01,0.1))\r\n}).store;\r\nNdef(\\delay, {\r\n\tvar src = In.ar(2,2);\r\n\tvar loc = LocalIn.ar(2)+src;\r\n\tloc = DelayC.ar(loc,1/~tp*2,LFNoise0.ar(~tp).range(0.125,1).round(0.25)/~tp);\r\n\tloc = FreqShift.ar(loc,LFNoise1.ar(3/~tp).range(-15,15));\r\n\tloc = loc+(loc ring4: WhiteNoise.ar(1*LFNoise1.ar(0.25)));\r\n\r\n\tLocalOut.ar(loc*0.5);\r\n\tPan2.ar(loc,SinOsc.ar(2))\r\n}).play\r\n)\r\n(\r\n{\r\n\tvar kick, snare, hihat, noise, fill1, rh1;\r\n\tfill1 = Pseq([Pseq([1],4),Pseq([0.125],8)],inf); // Fill used with a snare\r\n\trh1 = Pwrand([0.5,1,0.25,0.125],[0.75,0.15,0.05,0.05],inf); // Different hihat rhythm\r\n\t~freq = 60; // Fundamental Frequency\r\n\t~bar = 1/~tp*16; //\r\n\tkick = Pbind(*[\r\n\t\t\\instrument, \\sin,\r\n\t\tfreq: ~freq,\r\n\t\tlw: 0,\r\n\t\tindex: 10,\r\n\t\tlpF: 20000,\r\n\t\thpF: 40,\r\n\t\tmix: Pwhite(0.75,1),\r\n\t\tdur: 1/~tp,\r\n\t\tamp: 0.75,\r\n\t\tpan: 0,\r\n\t\tout: 0\r\n\t]);\r\n\tsnare = Pbind(*[\r\n\t\t\\instrument, \\sin,\r\n\t\tfreq: Pseq([\\rest,~freq],inf),\r\n\t\tlw: 1.5,\r\n\t\tindex: Pwhite(5000,7500),\r\n\t\tlpF: 15000,\r\n\t\thpF: 100,\r\n\t\tmix: Pwhite(0.25,0.5),\r\n\t\tdur: 1/~tp,\r\n\t\tamp: 0.3,\r\n\t\tpan: 0,\r\n\t\tout: 0\r\n\t]);\r\n\thihat = Pbind(*[\r\n\t\t\\instrument, \\sin,\r\n\t\tfreq: ~freq,\r\n\t\tlw: 1.5,\r\n\t\tindex: Pwhite(5000,15000),\r\n\t\tlpF: 17500,\r\n\t\thpF: 500,\r\n\t\tmix: Pwhite(0,0.5),\r\n\t\tdur: 0.5/~tp,\r\n\t\tamp: 0.125,\r\n\t\tpan: Pwhite(-1.0,1.0),\r\n\t\tout: Pwrand([0,2],[0.95,0.05],inf)\r\n\t]);\r\n\tnoise = Pbind(*[\r\n\t\t\\instrument, \\sin,\r\n\t\tfreq: ~freq*4,\r\n\t\tlw: 1,\r\n\t\tindex: Pwhite(150,300),\r\n\t\tlpF: 15000,\r\n\t\thpF: 2500,\r\n\t\tmix: Pwhite(0,1),\r\n\t\tdur: 4/~tp,\r\n\t\tamp: 0.1,\r\n\t\tpan: 0,\r\n\t\tout: 2\r\n\t]);\r\n\tPdef(\\kick, kick).play; ~bar.wait;\r\n\tPdef(\\snare, snare).play; ~bar.wait;\r\n\tPdef(\\hihat, hihat).play; ~bar.wait;\r\n\tPdef(\\hihat2, hihat).play;\r\n\tPbindef(\\hihat2, \\dur, 0.75/~tp); ~bar.wait;\r\n\tPdef(\\hihat3, hihat).play;\r\n\tPbindef(\\hihat3, \\dur, 0.25/~tp, \\amp, 0.125*Pseq([1,0.5],inf)); ~bar.wait;\r\n\tPbindef(\\snare, \\dur, fill1/~tp, \\freq, ~freq); ~bar.wait;\r\n\tPbindef(\\snare, \\dur, 1/~tp);\r\n\tPdef(\\kick).pause; ~bar.wait;\r\n\tPdef(\\kick, kick).play;\r\n\tPdef(\\noise, noise).play;\r\n\tPbindef(\\hihat2, \\dur, rh1/~tp, \\freq, ~freq*4);\r\n\r\n}.fork\r\n)",
   "id" : "1-50I",
   "is_private" : null,
   "labels" : [
      "beats",
      "algorithm",
      "composition"
   ]
}
