Skip to content

Instantly share code, notes, and snippets.

@edeleflie
Created July 28, 2011 12:36
Show Gist options
  • Save edeleflie/1111460 to your computer and use it in GitHub Desktop.
Save edeleflie/1111460 to your computer and use it in GitHub Desktop.
SuperCollider Example 2
// This SynthDef does Granular Synthesis
(
SynthDef(\granularish, {arg speed = 1, sndbuf ;
var b = 10, trate, dur, clk, pos, pan;
trate = MouseY.kr(8,120,1);
dur = 12 / trate;
clk = Impulse.kr(trate);
pos = MouseX.kr(0,BufDur.kr(b)) + TRand.kr(0, 0.01, clk);
pan = WhiteNoise.kr(0.6);
Out.ar(0, TGrains.ar(2, clk, sndbuf, speed, pos, dur, pan, 0.1) );
}).store();
)
// play the synth manually
b = Buffer.read(s, "sounds/a11wlk01-44_1.aiff"); // read sound file into memory
x = Synth(\granularish, [\sndbuf, b] ); // start the Synth
x.set(\speed, 0.3);
x.set(\speed, 0.7);
x.set(\speed, 0.8);
x.free;
// play the synth with patterns
(
b = Buffer.read(s, "sounds/a11wlk01-44_1.aiff");
Pmono(
\granularish,
\dur, Pseq([1, 1, 2], 3),
\sndbuf, b,
\speed, Pseq([0.6, 0.8, 1.2], 3)
).play
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment