{
   "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{\r\n\t//I've prepared a couple of arguments to qucikly change the sound, but don't hesitate to add more\r\n\t/*\r\n\ttempo= lfos and delay time, dist= max distortion, octRange= octave range, octOffset= first degree,\r\n\tfiltSpeef = speed of LPF modulation by LFTri, delLen= how many 4th notes the delay lasts (0 to 16),\r\n\tgrainDur= max duration of a grain, grainSpeed= max speed of Impulse multiplied by tempo\r\n\t*/\r\n\targ tempo = 0.5, dist=0.05, octRange=3, octOffset=24, filtSpeed=0.5, delLen=4, grainDur=0.25, grainSpeed=128;\r\n\tvar lfo1, winenv, env, scale, note, degreeNum, src, loc;\r\n\tlfo1 = {arg rt,lw,hg,rd; LFNoise0.ar(rt).range(lw,hg).round(rd)};//Arguments - Rate, Lowest Value, Highest Value, Round\r\n\t/*\r\n\tPitch Control\r\n\t*/\r\n\tscale = Scale.melodicMinor; //Sets the scale\r\n\tdegreeNum = scale.size-1; //Gets the number of degrees for the scale, I subtract 1 because the lfo works from 0.\r\n\tnote = DegreeToKey.ar(scale.as(LocalBuf),\r\n\t\tlfo1.(tempo*2,0,degreeNum*octRange,lfo1.(tempo/2,1,7,1)),//lfo1.(rate=2,lowNum=0,highNum=degreeNum*4(4 octaves),round=another lfo\r\n\t\tscale.stepsPerOctave,1,octOffset).midicps;\r\n\t/*\r\n\tSource\r\n\t*/\r\n\twinenv = Env([0,0.5,0.25,1,0],[0.5,0.25,0.5],[8,-8]);\r\n\tenv = Buffer.sendCollection(s,winenv.discretize,1);\r\n\tsrc = GrainSin.ar(2,\r\n\t\tImpulse.ar(lfo1.(tempo/4,tempo*(grainSpeed/8),tempo*grainSpeed,tempo)),\r\n\t\tlfo1.(tempo*3,grainDur/16,grainDur,grainDur/16),note,lfo1.(tempo*4,-1,1,0.1),\r\n\t\tenv, 1024, 0.5);\r\n\t/*\r\n\tFeedback\r\n\t*/\r\n\tloc = LocalIn.ar(2)+src;\r\n\tloc = DelayL.ar(loc,1/tempo*4,1/tempo*delLen); //delLen 4th Notes at a given tempo (90BPM in this case)\r\n\tloc = loc + //Loc + Filtered/FrequencyShifted/Distorted Loc Parameters are modulated with lfo1 function (LFNoise0)\r\n\tLPF.ar(\r\n\t\tFreqShift.ar(\r\n\t\t\t((loc*lfo1.(tempo*2,1,25,1)).softclip*LFSaw.ar(tempo/16,0,dist).abs)\r\n\t\t\t,lfo1.(tempo/4,-1,1,1)*note*4),\r\n\t\t3000);\r\n\tloc = LPF.ar(loc, LFTri.ar(tempo*filtSpeed,0,2500,2500).abs); //Simple Low Pass Filter, Freq controlled by Triangle Wave\r\n\t2.do{loc = AllpassC.ar(loc,0.5,LFNoise1.ar(0.005!2,0.05,0.125).abs,1)}; //Higher/Lower 'do' value will result in more/less noisy sound\r\n\tloc = LeakDC.ar(loc);\r\n\r\n\tLocalOut.ar(loc*1.25);\r\n\tLimiter.ar(loc)*0.95\r\n}.play\r\n)",
   "id" : "1-50K",
   "is_private" : null,
   "labels" : [
      "ambient",
      "noise",
      "experimental"
   ],
   "description" : "A patch I made today that explores GrainSin with feedback with FreqShift and Allpass chain. Mess around with parameters, if you get something nice, let me know :)",
   "ancestor_list" : [],
   "author" : "rumush",
   "name" : "GrainSin and Feedback"
}
