In Spark AR Studio, a unit of execution is known as a frame. One frame covers the entire execution cycle, from the input to the final output. A set of inputs are processed to produce a set of outputs, for example an image or sound.
The Delay Value patch delays the given input by one frame, outputting the input value from the previous frame, onto the next frame. This means you can take the output of a patch and connect it to a patch that’s connected before it in your graph.
This cyclical relationship, enabled by the Delay Value patch, isn't normally possible in the Patch Editor. The examples below demonstrate the new possibilities that this provides.
Compatible data types
The input value can be a number, boolean, pulse or vector2, 3, 4 data type. By default the value is a number.
Name | Description |
---|---|
Initial Value | The initial value to output until the input value is provided in the value input port. |
Value | The input value that is delayed by one frame in the output. |
Name | Description |
---|---|
Make a receiver from this patch to access the output. Right click the patch and select Make Receiver. |
In the below example below, the 3D heart object is rotating on its Y axis every frame.
Instead of outputting the input value in the same frame, The Delay Value Patch at the end of the graph delays the input value and feeds it back into the Delay Value sender patches.
The input value of the Delay Value patch is it’s own delayed output plus an additional 5 degrees. We added 5 in the Add patch to increment the value by an additional 5 degrees on every frame.
Store Value is a patch asset created using a Delay Value patch. This patch asset stores an input value the instant a pulse is fired. The Input can be a value of any data type. The Store Trigger input takes a pulse as a trigger. The Output is the currently stored value.
When the Store Value patch asset is ungrouped you see that it also contains a Delay Value patch and a Pulse to Bool patch asset:
The Pulse to Bool patch asset converts a pulse signal into a boolean value. When ungrouped, you see it also contains its own Delay Value patch:
We used a Store Value patch asset in the graph below:
The Input for the Store Value patch asset is the Time from the Runtime patch, i.e. the number of seconds since the effect started running. When the time reaches an odd number (with a Tolerance of 0.05), a signal is sent which triggers the Store Value patch asset to store the running value. This value is converted to a text string that appears on the device screen.
You can see the result of the entire graph in the Simulator below. The red text shows the stored value, at the instant the running value (in black text) turns into an odd number. This transition moment is shown by the green text turning from 0 to 1.
Download the Store Value project to explore the example yourself.
Open AR Library from Spark AR Studio to find and download the following patch assets, all of which contain Delay Value patches.