Delay by number of frames
This patch expands on Origami’s Delay1 patch allowing you to set duration by a user defined (loopable) number frames.
Example
This example included in the project uses Delay 1x for a motion blur effect by inputing a Loop for the number of frames. This creates a trail of duplicate layers that follow the first layer wherever it goes, each offset by 1 frame from the preceding .
Previously to do this, you would have to chain multiple Delay 1 patches. Say you wanted a 4 frame delay, you would have to wire 4 Delay 1 patches together. They would have to be hardwired meaning durations couldn't be set programmatically and wouldn't allow for the use of loops to determine duration.
Works for any value type
A little pro tip here. If you are making a component patch that you want to work for any type, set inputs and outputs to JSON. Origami will automatically build a JSON Object that will hold any value you throw at it. You just need to make sure you set the same type for the following patch in your patch network.
How it works
The heart of this patch is a “feedback loop” created connected to Join Array. Feedback loops (not to be confused with Loops) in Origami happen when a patch's output is wired up to on of its inputs. In this case a new value comes into the first input of the Join Array and the output of the Join Array is fed into the second input (taking a detour through other patches on the way back). This results in an ever growing array that records a new value every frame and places that new value at the beginning of the Array. A Subarray patch is used to limit the number of values the Array keeps trimming off older values as it goes. In this case Subarray length number is the frame duration for the delay component. These feedback loops are very good at recording every frame and work much better than using Loops to build an equivalent frame recorder