Documents
Writing Docs Gigedit SFZ Instrument Scripts NKSP Language NKSP Reference

wait()

Suspends / pauses execution of the current event handler instance for the requested amount of microseconds. The paused event handler instance can also be resumed before the requested amount times elapsed by calling stop_wait() from another event handler instance.

The duration-us argument must neither be negative nor zero, otherwise script execution will be aborted, because this is a common indication of bugs in scripts which could potentially lead to real-time instability or worse scenarios otherwise.

If the even handler instance's built-in variable $NKSP_IGNORE_WAIT reflects 1 then all calls to wait() will be ignored. This might for example be the case when stop_wait() with 1 being passed to the 2nd argument of that function.

Function Prototype

wait(duration-us)

Arguments

Argument Name Data Type Description
duration-us Integer Number Positive (non zero) amount of microseconds to pause execution.
[required]

Return Value

None.

Examples

Using the wait() function can lead to concurrency issues with regular variables, which are global variables by default. You might need to use polyphonic variables in such cases. You need at least LinuxSampler 2.0.0.svn2 or higher for the wait() function to fully work as expected. Versions of LinuxSampler older than that will not resume the script at the requested amount of time, instead those older version will resume the script always at the beginning of the next audio fragment cycle. So effectively a wait() call with a LinuxSampler version older than 2.0.0.svn2 will pause your script for a few miliseconds, no matter which function argument you provided.
Document Updated:  2016-07-22  |  Author:  Christian Schoenebeck