Skip to content

Instantly share code, notes, and snippets.

@eleses
eleses / gist:0720ba5af1f1361308f75f1076aba8be
Created June 17, 2020 16:07
Cleanups dupe fix, beta 1
CleanupThunk : AbstractFunction {
var function, value;
*new { arg function;
^super.newCopyArgs(function)
}
value { |... args| ^this.prEvaluate(\valueArray, args) }
valueArray { |... args| ^this.prEvaluate(\valueArray, *args) }
valueEnvir { |... args| ^this.prEvaluate(\valueArrayEnvir, args) }
// When you want to Plazy a Pfunc but still want to get resetFunc called
// use this instead. See https://bit.ly/37t90WA for more
PfuncLazy : Pattern {
var <>func;
*new { |func| ^super.newCopyArgs(func) }
asStream { |inval|
var nextFunc, resetFunc;
// don't need it for my use(s) to have inval passed to func
// but nice to have maybe
@eleses
eleses / Cleanup_unittest.scd
Last active May 23, 2020 12:59
Cleanup unittest; now with working Ppar
/* an UnitTestScript for cleanup chaining */
{ |test|
var exhaust = { arg pat, ie = ();
var cu = EventStreamCleanup.new, oe = nil, str = pat.asStream;
var hist = List().add(cu.functions.size);
while({
oe = str.next(ie);
cu.update(ie);
hist.add(cu.functions.size);
//[\ULEC, oe, ie, cu.functions.size].postln;
@eleses
eleses / PprotoU.sc
Created March 8, 2020 06:18
Fixing the user-supplied cleanup function behavior in Pproto (working draft; there's an inherited "double cleanup.exit" bug unresolved)
PprotoU : Pattern {
var <>makeFunction, <>pattern, <>userCleanupFunc; // distinguish from the combo one we'll generate
*new { | makeFunction, pattern, cleanupFunc|
^super.newCopyArgs( makeFunction, pattern, cleanupFunc)
}
storeArgs { ^[makeFunction,pattern,userCleanupFunc] }
embedInStream { | event |
var stream, ev, evType;
@eleses
eleses / PfsetC-test.scd
Last active March 7, 2020 22:42
A Pfset with closure
p = Pbind(\dur, Pseq([1, 2, inf]));
(r = PfsetC({var grp = Group(); ~group = grp;
{ grp.release.postln; fork { 3.wait; grp.free }}}, p).play);
r.reset; // /hit a few time before it reaches the infinite event
r.stop; // several groups freed.