Skip to content

Instantly share code, notes, and snippets.

@halldorel
Last active December 17, 2018 22:41
Show Gist options
  • Save halldorel/9aa33ec3d9935fe97150c862614b4d21 to your computer and use it in GitHub Desktop.
Save halldorel/9aa33ec3d9935fe97150c862614b4d21 to your computer and use it in GitHub Desktop.
s = Server.local
s.boot
s.reboot;
s.options.inDevice = "Built-in Microph"
s.options.inDevice = "Duet USB"
s.options.outDevice = "Built-in Audio"
s.options.outDevice = "Soundflower (2ch)"
s.options.inDevice;
s.options.outDevice;
(
~buffers = Buffer.alloc(s, 44100 * 10 * 16, 1);
// Live slices incoming audio
(
SynthDef("slicer2", {|out|
var in, amp, sound, chain, onsets, pips, pulseCount, pulseWrapped, bufferPlayer, env, env2;
env = Env([0, 1, 1, 1, 0], [0.5, 0.5, 0, 2]).dup(16);
// in = Mix.new(SoundIn.ar(0));
in = Mix.new(PlayBuf.ar(2, ~buf, BufRateScale.kr(~buf)));
bufferPlayer = Array.newClear(16);
chain = FFT(LocalBuf(1024, 2), in);
onsets = Onsets.kr(chain, threshold:0.5, odftype: 'rcomplex', relaxtime: 4);
pips = WhiteNoise.ar(EnvGen.kr(Env.perc(0.001, 0.1, 0.2), onsets));
pulseCount = PulseCount.kr(onsets);
//RecordBuf.ar(in, ~buffers, 0, trigger:onsets);
RecordBuf.ar(Silent.ar(1), ~buffers, offset: ((pulseCount + 1) % 16) * 44100 * 10, trigger: onsets);
/* Routine({
~buffers.setn(((pulseCount + 1) % 16) * 44100 * 10, Array.fill(44100 * 10, {0}));
}).next(onsets);*/
RecordBuf.ar(in, ~buffers, offset: (pulseCount % 16) * 44100 * 10, trigger: onsets);
16.do { |i|
bufferPlayer[i] = LPF.ar(PlayBuf.ar(1, ~buffers,BufRateScale.kr(~buffers), startPos:((pulseCount-1+i)%16) * 441000, trigger: onsets) * EnvGen.kr(env[i], gate: onsets, doneAction: 2), (((16-(pulseCount-1+i)%16))/16) * 10000 + 50 );
};
//Out.ar(out, Mix.ar([Pan2.ar(in, 0.0), FreeVerb.ar(Pan2.ar(bufferPlayer[0], -0.7)), FreeVerb.ar(Pan2.ar(bufferPlayer[1], 0.7))]));
Out.ar(out,in + pips + FreeVerb.ar(Splay.ar(bufferPlayer), 0.02, 0.9));
}).play;
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment