Created
August 21, 2020 14:25
-
-
Save scztt/e53046e866e75e48bff1b62311da96eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Only pull a value once per clock time - else, return the previous value | |
PtimeClutch : FilterPattern { | |
var <>delta; | |
*new { | |
|pattern, delta=0.0| | |
^super.new(pattern).delta_(delta); | |
} | |
embedInStream { | |
|input| | |
var lastTime, lastVal; | |
var stream = pattern.asStream; | |
loop { | |
var thisTime = thisThread.beats; | |
if (lastTime.isNil or: { (thisTime - lastTime) > delta }) { | |
lastVal = stream.next(input); | |
lastTime = thisTime; | |
}; | |
input = lastVal.copy.yield; | |
} | |
} | |
} | |
+Pattern { | |
timeClutch { | |
|delta=0.0| | |
^PtimeClutch(this, delta) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment