Skip to content

Instantly share code, notes, and snippets.

@ALOUT
Last active August 29, 2015 14:02
Show Gist options
  • Save ALOUT/b844a8b5ab5b63cf1d4b to your computer and use it in GitHub Desktop.
Save ALOUT/b844a8b5ab5b63cf1d4b to your computer and use it in GitHub Desktop.
簡易ドラムマシン テンプレート(Pbind Sequence) -> BBCut2
s.boot;
s.quit;
(
SynthDef(\drums, {|out = 0, bassLevel = 0,
snareLevel = 0, hatLevel = 0, tomLevel = 0,
pan1 = 0, pan2 = 0, pan3 = 0, pan4 = 0|
var env1, env2, env3, bass, snare, hat, tom, bassOut, snareOut,
hatOut, tomOut, mixer;
env1 = EnvGen.kr(Env.perc(0.001, 0.2, 1, -4), 1, doneAction:2);
env2 = EnvGen.kr(Env.perc(0.002, 0.3, 1, -2), 1, doneAction:2);
env3 = EnvGen.kr(Env.perc(0.001, 0.1, 1, -5), 1, doneAction:2);
bass = SinOsc.ar(80) + Crackle.ar(1, 0.5);
bassOut = Pan2.ar(bass*env1, pan1, bassLevel);
snare = SinOsc.ar(40) - WhiteNoise.ar(0.5, 0.5);
snareOut = Pan2.ar(snare*env1, pan2, snareLevel);
hat = Klank.ar(`[ [ 6563, 9875 ],
[ 0.61, 0.55046827363918 ],
[ 0.0024, 0.0036 ] ], PinkNoise.ar(1));
hatOut = Pan2.ar(hat*env2, pan2, hatLevel);
tom = SinOsc.ar(440);
tomOut = Pan2.ar(tom*env3, pan4, tomLevel);
mixer = (bassOut + snareOut) + (hatOut + tomOut);
Out.ar(out, mixer);
}).store
)
TempoClock.default.tempo_(3);
(
var buf, clock, bbcutgroup,counter;
~synthbus = Bus.audio(s,2);
~synthgroup= Group.head(Node.basicNew(s,1));
a = Pseq ([1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]);
b = Pseq ([0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0]);
c = Pseq ([0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0]);
d = Pseq ([0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1]);
p = Pbind(
\instrument, \drums,
\dur, 0.2,
\bassLevel, Pseq ([a], inf),
\snareLevel, Pseq ([b], inf),
\hatLevel, Pseq ([c], inf),
\tomLevel, Pseq ([d], inf),
\group, ~synthgroup,
\out, ~synthbus
).play;
clock= ExternalClock(TempoClock.default);
bbcutgroup= Group.after(~synthgroup);
counter=159;
Routine.run({
buf= BBCutBuffer.alloc(s,44100,2);
s.sync; //this forces a wait for the Buffer to be allocated
//BBCut2(CutGroup(CutStream1(~synthbus.index, buf, 0.75, 0.01, 0.4,40,3,10),bbcutgroup, numChannels:2), SQPusher2(quant:{[0.25,0.0,0.75,0.50].wchoose([0.9,0.1])})).play(clock);
//BBCut2(CutGroup(CutStream2(~synthbus.index, buf, 0.5, 0.51, 0.4,0.4,3,-10),bbcutgroup, numChannels:2),SQPusher2({arg data; counter=counter+1; data.wrapAt(counter)},{arg bar; bar.clump(2)})).play(clock);
BBCut2(CutGroup(CutStream1(~synthbus.index, buf, 0.75, 0.01, 0.4,40,3,10),bbcutgroup, numChannels:2), CageCut.new(44.0,[1,3,3,1,0.8,2,3,1,4,5])).play(clock);
//BBCut2(CutGroup(CutStream1(~synthbus.index, buf, 0.75, 0.31, 0.4,40,3,10),bbcutgroup, numChannels:2),CageCut({[32.0,16.0,8.0,4.0].wchoose([0.9,0.6,0.3,0.1])},[4,3,2,5,2,1,7],{arg array; if(0.1.coin,{array.scramble;},{array.permute(100.rand)}); })).play(clock);
//BBCut2(CutGroup(CutStream1(~synthbus.index, buf, 0.75, 0.01, 0.4,40,3,10),bbcutgroup, numChannels:2), ThrashCutProc1.new({[0.7,0.2].choose},{[0.125,0.5].choose}, 7, {[0.2,0.2,0.1,0.1,0.2,0.2]},{2.rand+2},{5.rand})).play(clock);
});
clock.play;
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment