Skip to content

Instantly share code, notes, and snippets.

@lvm
Last active March 5, 2018 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lvm/ee9939c359a1255fecbd16724331efff to your computer and use it in GitHub Desktop.
Save lvm/ee9939c359a1255fecbd16724331efff to your computer and use it in GitHub Desktop.
Psoftclip : FilterPattern {
var <>lo, <>hi;
*new { arg pattern,lo,hi;
^super.new(pattern).lo_(lo).hi_(hi)
}
storeArgs { ^[pattern,lo,hi] }
embedInStream { arg event;
var next;
var stream = pattern.asStream;
var loStr = lo.asStream;
var hiStr = hi.asStream;
var loVal, hiVal;
while({
loVal = loStr.next(event);
hiVal = hiStr.next(event);
next = stream.next(event);
next.notNil and: { loVal.notNil } and: { hiVal.notNil }
},{
event = next.softclip(loVal, hiVal).yield
});
^event;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment