{
   "is_private" : null,
   "id" : "1-55M",
   "code" : "// =================================\r\n// A4 - musc-115-granular\r\n// GRANULAR SAMPLING\r\n// =================================\r\n\r\n/*\r\nThe code below is exactly what we built in class.\r\nYou will need a MONO sample.\r\n\r\n*/\r\n\r\n// make sure to boot server first\r\n\r\n// load a sound file (or two...)\r\nb = Buffer.read(s, \"/Users/Mason/Desktop/Nena ‎- 99 Luftballons mono.wav\");\r\nc = Buffer.read(s, \"/Users/Mason/Desktop/Sweet Dreams Eurythmics mono.wav\");\r\n\r\n// buffer handy tools:\r\nb.play;\r\n// check number of channels\r\nb.numChannels;\r\n// check duration\r\nb.duration;\r\n// check how many samples are in the sample\r\nb.numFrames;\r\n\r\nc.play;\r\n\r\n// SynthDefs\r\n(\r\n// simple synthdef, no filters or effects, just env and panning control\r\nSynthDef(\"granny1\", {arg rate = 1, amp = 1, buffer, startPos = 0, attack = 0.02, release = 0.5, panning = 0;\r\n    var snd, env;\r\n    env = Env.perc(attackTime: attack, releaseTime: release, level: amp).kr(doneAction: 2);\r\n    snd = PlayBuf.ar(\r\n        numChannels: 1,\r\n        bufnum: buffer,\r\n        rate: rate,\r\n        startPos: startPos.linlin(0, 1, 0, BufFrames.kr(buffer))\r\n    );\r\n    snd = snd * env;\r\n\tsnd = Pan2.ar(snd, panning);\r\n    Out.ar(0, snd);\r\n}).add;\r\n\r\n// Same as above, but adding a filter just for fun\r\nSynthDef(\"granny2\", {arg rate = 1, amp = 1, buffer, startPos = 0, attack = 0.02, release = 0.5, ffreq = 1000, rq = 0.1, panning = 0;\r\n    var snd, env;\r\n    env = Env.perc(attackTime: attack, releaseTime: release, level: amp).kr(doneAction: 2);\r\n    snd = PlayBuf.ar(\r\n        numChannels: 1,\r\n        bufnum: buffer,\r\n        rate: rate,\r\n        startPos: startPos.linlin(0, 1, 0, BufFrames.kr(buffer))\r\n    );\r\n    snd = snd * env;\r\n    snd = BPF.ar(snd, ffreq, rq);\r\n    snd = Pan2.ar(snd, panning);\r\n    Out.ar(0, snd);\r\n}).add;\r\n\r\n// Same as above, but adding an echo effect (CombC)\r\nSynthDef(\"granny3\", {arg rate = 1, amp = 1, buffer, startPos = 0, attack = 0.02, release = 0.5, ffreq = 1000, rq = 0.1, panning = 0, delay = 0.3, decay = 1;\r\n    var snd, env;\r\n    env = Env.perc(attackTime: attack, releaseTime: release, level: amp).kr(doneAction: 2);\r\n    snd = PlayBuf.ar(\r\n        numChannels: 1,\r\n        bufnum: buffer,\r\n        rate: rate,\r\n        startPos: startPos.linlin(0, 1, 0, BufFrames.kr(buffer))\r\n    );\r\n    snd = snd * env;\r\n    snd = BPF.ar(snd, ffreq, rq);\r\n\tsnd = CombC.ar(snd, maxdelaytime: 2, delaytime: delay, decaytime: decay);\r\n    snd = Pan2.ar(snd, panning);\r\n    Out.ar(0, snd);\r\n}).add;\r\n\r\n\r\n\r\n)\r\n\r\n// Some testing Pbinds\r\n\r\n// One\r\n(\r\n~one = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([6, ]),\r\n\t\\amp, 2, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.8,\r\n\t\\ffreq, Pseq([300], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 1.5,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n~one.play;\r\n// Two\r\n(\r\n~two = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([5, ], ),\r\n\t\\amp, 2, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.8,\r\n\t\\ffreq, Pseq([250], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 2.5,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n~two.play;\r\n\r\n// Three (this one uses granny2, with the filter)\r\n(\r\n~three = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([1, ], inf),\r\n\t\\amp, 10, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.7,\r\n\t\\ffreq, Pseq([375], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 0.45,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n~three.play\r\n\r\n\r\n(\r\n~four = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([1, ], inf),\r\n\t\\amp, 10, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.7,\r\n\t\\ffreq, Pseq([475], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 0.45,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n~four.play\r\n\r\n\r\n(\r\n~five = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([1, ], inf),\r\n\t\\amp, 10, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.7,\r\n\t\\ffreq, Pseq([575], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 0.45,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n\r\n~five.play;\r\n\r\n(\r\n~six = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([1, ], inf),\r\n\t\\amp, 10, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.7,\r\n\t\\ffreq, Pseq([775], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 0.45,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n\r\n~six.play;\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n);\r\n\r\n(\r\n~seven = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([1, ], inf),\r\n\t\\amp, 10, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.7,\r\n\t\\ffreq, Pseq([335], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 0.45,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n\t\r\n);\r\n\r\n(\r\n~eight = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([1,1, 1, 1],),\r\n\t\\amp, 10, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.7,\r\n\t\\ffreq, Pseq([375], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 0.45,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n\r\n(\r\n~nine = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([1,1,1 ],),\r\n\t\\amp, 10, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.7,\r\n\t\\ffreq, Pseq([475], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 0.45,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n(\r\n~ten = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([1,1,1 ],),\r\n\t\\amp, 10, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.7,\r\n\t\\ffreq, Pseq([575], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 0.45,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n\r\n(\r\n~eleven = Pbind(\r\n    \\instrument, \"granny2\", // notice I'm using granny2 synthdef here\r\n\t\\rate, Pseq([1,1,1 ],),\r\n\t\\amp, 10, // boosted to 5 because filtering attenuates a lot of the sound\r\n\r\n    \\attack, 0.06,\r\n    \\release, 0.7,\r\n\t\\ffreq, Pseq([650], inf),\r\n\t\\rq, 0.11,\r\n    \\buffer, c, // which buffer to play from\r\n    \\dur, 0.45,\r\n\t\\panning, Pwhite(-0.5, 0.5)\r\n);\r\n)\r\n\r\n\r\n\r\n\r\n\r\n)\r\n\r\n~one.play;\r\n~two.play;\r\n~three.play;\r\n~four.play;\r\n~five.play;\r\n~seven.play;\r\n~eight.play;\r\n~nine.play;\r\n~ten.play;\r\n~eleven.play;\r\n(\r\n{\r\n\r\n~threeplay=~three.play;\r\n4.8.wait;\r\n~threeplay.stop;\r\n~fourplay=~four.play;\r\n4.8.wait;\t\r\n~fourplay.stop;\r\n~fiveplay=~five.play;\t\r\n4.8.wait;\r\n~fiveplay.stop;\t\r\n~sixplay=~six.play;\r\n1.2.wait;\r\n~sixplay.stop;\r\n~fiveplay=~five.play;\r\n1.2.wait;\r\n~fiveplay.stop;\r\n~fourplay=~four.play;\r\n1.2.wait;\r\n~fourplay.stop;\r\n~eightplay=~eight.play;\r\n1.2.wait;\r\n~sevenplay=~seven.play;\r\n1.2.wait;\r\n~sevenplay.stop;\r\n~eightplay=~eight.play;\t\r\n\t\r\n\t\r\n\t\r\n\t\r\n\t\r\n2.wait;\r\n~oneplay=~one.play;\r\n0.5.wait;\r\n~oneplay.stop;\t\r\n~eightplay=~eight.play;\r\n2.wait;\r\n~oneplay=~one.play;\r\n0.5.wait;\r\n~oneplay.stop;\t\r\n~nineplay=~nine.play;\r\n2.wait;\r\n~twoplay=~two.play;\r\n~nineplay.stop;\t\r\n0.5.wait;\r\n~twoplay.stop;\t\r\n~nineplay=~nine.play;\r\n2.wait;\r\n~twoplay=~two.play;\t\r\n~nineplay.stop;\r\n0.5.wait;\r\n~tenplay=~ten.play;\r\n2.wait;\r\n~oneplay=~one.play; \r\n0.5.wait;\r\n~oneplay.stop;\r\n~tenplay=~ten.play;\r\n2.wait;\r\n~oneplay=~one.play;\r\n~tenplay.stop;\t\r\n0.5.wait;\r\n~elevenplay=~eleven.play;\r\n1.2.wait;\t\r\n~nineplay=~nine.play;\r\n1.2.wait;\r\n~eightplay=~eight.play;\r\n1.2.wait;\r\n~sevenplay=~seven.play;\r\n1.2.wait;\r\n~sevenplay.stop;\r\n~eightplay=~eight.play;\r\n\t\r\n2.wait;\r\n~oneplay=~one.play;\r\n0.5.wait;\r\n~oneplay.stop;\t\r\n~eightplay=~eight.play;\r\n2.wait;\r\n~oneplay=~one.play;\r\n0.5.wait;\r\n~oneplay.stop;\t\r\n~nineplay=~nine.play;\r\n~elevenplay=~eleven.play;\r\n1.2.wait;\t\r\n~nineplay=~nine.play;\r\n1.2.wait;\r\n~eightplay=~eight.play;\r\n1.2.wait;\r\n~sevenplay=~seven.play;\r\n1.2.wait;\r\n~sevenplay.stop;\r\n\t\r\n\t\r\n\t\r\n\t\r\n\t\r\n\t\r\n\t\r\n\t\r\n\r\n\r\n\r\n\t\r\n\r\n\t\r\n\r\n\t\r\n}.fork;\r\n)",
   "labels" : [],
   "ancestor_list" : [],
   "description" : "",
   "name" : "rough draft final",
   "author" : "Mason McCormack"
}
