Skip to content

Instantly share code, notes, and snippets.

@lvm
Last active April 21, 2017 22:00
Show Gist options
  • Save lvm/ee6b5636c4b74f3b57dfec29b1039996 to your computer and use it in GitHub Desktop.
Save lvm/ee6b5636c4b74f3b57dfec29b1039996 to your computer and use it in GitHub Desktop.
TempoClock.default.tempo_(120/60);
b = Buffer.alloc(s,44100);
(
~samplesDir = thisProcess.nowExecutingPath.dirname ++ "/samples";
~samples = Array.fill(32, {
|i, str|
str=(~samplesDir++"/amen/"++(i)++".wav".asString);
str;
});
~lengths = Array.fill(~samples.size / 4, {
[1,1,Rest(1),1].scramble;
}).flat;
~breaks = Array.fill(~lengths.size, {
|i|
Buffer.read(s,~samples[i])
});
)
(
SynthDef(\break,
{|out, bufnum=0, sample=0, pan=0|
var pb, brk, env, sr;
sr = 44100;
env = EnvGen.ar(Env.perc, doneAction:2);
pb = PlayBuf.ar(1, sample, loop:0);
brk = Breakcore.ar(bufnum, pb, Impulse.kr(LFNoise0.kr(4,10,12)), Rand(sr/4, sr), 0) * env;
OffsetOut.ar(out, Pan2.ar(brk, pan));
}).add;
SynthDef(\sampler,
{|out, amp=0.9, atk=0.01, rel=1, pos=0, sample=0, rate=1, pan=0|
var sig, env, begin, sr;
sr = 44100;
begin = BufDur.kr(sample)*sr * pos;
env = EnvGen.ar(Env.linen(0.0,rel,0.0,1));
sig = PlayBuf.ar(1, sample, rate:BufRateScale.ir(sample) * rate, trigger:1, startPos:begin, loop:0, doneAction:2);
sig = sig * env * amp;
Out.ar(out,Pan2.ar(sig, pan));
}).add;
)
(
Pdef(\brk,
Pbind(
\instrument, Pseq([\sampler,\break], inf),
\amp, 0.9,
\sample, Pstutter(Pwrand([1,4,8],[0.9,0.075,0.025],inf), Pxrand(~breaks.do{ |b| b.bufnum },inf)),
\dur, Pxrand(~lengths, inf)/4,
\rate, Pwrand([0.8, 1, 2], [0.9, 0.05, 0.05], inf),
\pan, Pwhite(-0.25, 0.25, inf),
\out, ~chan[0]
)
);
)
Pdef(\brk).play(quant:4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment