time_warp delta_time (number)
The code within the given block is executed with the specified delta time shift specified in beats. For example, if the delta value is 0.1 then all code within the block is executed with a 0.1 beat delay. Negative values are allowed which means you can move a block of code backwards in time. For example a delta value of -0.1 will execute the code in the block 0.1 beats ahead of time. The time before the block started is restored after the execution of the block.
Given a list of times, run the block once after waiting each given time. If passed an optional params list, will pass each param individually to each block call. If size of params list is smaller than the times list, the param values will act as rings (rotate through). If the block is given 1 arg, the times are fed through. If the block is given 2 args, both the times and the params are fed through. A third block arg will receive the index of the time.
Note that the code within the block is executed synchronously with the code before and after, so all thread locals will be modified inline - as is the case for with_fx
. However, as time is always restored to the value before time_warp
started, you can use it to schedule events for the future in a similar fashion to a thread (via at
or in_thread
) without having to use an entirely fresh and distinct set of thread locals - see examples.
Also, note that you cannot travel backwards in time beyond the current_sched_ahead_time
.
If the time_warp
block is within a density
block, the delta time is not affected (although all the other times such as sleep and phase durations will be affected) - see example.
time_warp
is ahead-of-time scheduling within the current thread. See at
for just-in-time scheduling using multiple isolated threads.
Introduced in v2.11
# Example 1 | |
|
|
# Example 2 | |
|
|
# Example 3 | |
|
|
# Example 4 | |
|
|
# Example 5 | |
|
|
# Example 6 | |
|
|
# Example 7 | |
|
|
# Example 8 | |
|
|
# Example 9 | |
|
|
# Example 10 | |
|
|
# Example 11 | |
|
|
# Example 12 | |
|
|
# Example 13 | |
|
|
# Example 14 | |
|
|
# Example 15 | |
|
|