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