Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Assignment 3 115granular
name
code content
// load a sound file (or two...) b = Buffer.read(s, "/Users/alg31/Downloads/bad-mono.wav"); c = Buffer.read(s, "/Users/alg31/Downloads/but-music.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; //SynthDefs ( 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; ) // Pbinds ( ~one = Pbind( \instrument, "granny1", \rate, Pseq([0.4, 0.42, 0.44, 0.48, 0.5, 0.52, 0.54, 0.56], inf), // notice this one ENDS after 4 cycles \amp, 1, \startPos, 0.19, \attack, 0.01, \release, 0.23, \buffer, b, // which buffer to play from \dur, Pseq([Pn(1/2, 8), Pn(1/4, 16)], inf), ); ~two = Pbind( \instrument, "granny1", \rate, Pseq([0.19, 0.19, 0.19, 0.25], inf), \amp, 0.3, \startPos, 0.1, \attack, 2.3, \release, 0.5, \buffer, c, // which buffer to play from \dur, 2.5, ); ~three = Pbind( \instrument, "granny2", // notice I'm using granny2 synthdef here \rate, Pseq([-1, 2], inf), \amp, 5, // boosted to 5 because filtering attenuates a lot of the sound \startPos, 0.1, \attack, 0.02, \release, 0.4, \ffreq, Pseq([9000, 2000, 2030, 9100], inf), \rq, 0.01, \buffer, b, // which buffer to play from \dur, 0.25, \panning, Pwhite(-0.5, 0.5) ); ~three3 = Pbind( \instrument, "granny2", // notice I'm using granny2 synthdef here \rate, Pseq([-1, 2], inf), \amp, 5, // boosted to 5 because filtering attenuates a lot of the sound \startPos, 0.09, //Pseq([0.24, 0.33, 0.66, 0.89], inf), \attack, 0.02, \release, 0.4, \ffreq, Pseq([9000, 2000, 2030, 9100], inf), \rq, 0.01, \buffer, b, // which buffer to play from \dur, 0.5, ); ~one1 = Pbind( \instrument, "granny1", \rate, 0.2, 0.2, \rest, 0.7, 0.6, 0.8, \rest, 0.8, \rest, \amp, 1, \startPos, 0.18, \attack, 0.03, \release, 0.1, \buffer, b, // which buffer to play from \dur, Pseq([1/4, 1/4, Rest(1/2), Pn(1/6, 3), Rest(1/6), 1/6, Rest(1/6)], inf), ); ~four = Pbind( \instrument, "granny3", \rate, Pseq([-1, 2, 3, 3], inf), \amp, 5, \startPos, 0.7, \attack, 0.3, \release, 0.2, \ffreq, Pseq([700, 200, 400, 550], inf), \rq, 0.01, \delay, 0.2, \decay, 2, \buffer, b, // which buffer to play from \dur, 0.25, ); ~two2 = Pbind( \instrument, "granny2", \rate, -2, \amp, 0.3, \startPos, 0.94, \attack, 0.09, \release, 0.1, \buffer, b, // which buffer to play from \dur, Pn(0.25, 8), ); ) ( Pspawner({ arg maestro; ~player2=maestro.par(~two); 10.wait; maestro.suspend(~player2); ~player22=maestro.par(~two2); 2.wait; maestro.suspend(~player22); ~player1= maestro.par(~one); 6.wait; ~player22=maestro.par(~two2); 2.wait; maestro.suspend(~player22); maestro.suspend(~player1); ~player3=maestro.par(~three); ~player33=maestro.par(~three3); 12.wait; ~player11=maestro.par(~one1); 4.wait; ~player22=maestro.par(~two2); 4.wait; maestro.suspend(~player22); 4.wait; ~player22=maestro.par(~two2); 4.wait; maestro.suspend(~player11); maestro.suspend(~player22); 4.wait; maestro.suspend(~player3); maestro.suspend(~player33); ~player22=maestro.par(~two2); 4.wait; maestro.suspend(~player22); ~player4=maestro.par(~four); 4.wait; maestro.suspend(~player4); ~player22=maestro.par(~two2); 4.wait; maestro.suspend(~player22); ~player2=maestro.par(~two); 6.wait; maestro.suspendAll; }).play; )
code description
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change