-
-
Save iTerentius/6f25fcad1fab7260516bbee094b95866 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