This document gives you an overview of all built-in functions and built-in variables provided by the NKSP real-time instrument script language.
These are the built-in functions available with the NKSP realt-time instrument script language.
Most fundamental NKSP functions, independent from any purpose of being used in a sampler.
Function | Description |
---|---|
message() |
Prints text to the sampler's terminal. |
exit() |
Stops execution of the current event handler instance. |
wait() |
Pauses execution for a certain amount of time. |
abs() |
Calculates the absolute value of a given value. |
random() |
Random number generator. |
num_elements() |
Returns the size of the requested array variable. |
Basic sampler related functions, independent from a particular sampler format or sampler engine.
Function | Description |
---|---|
play_note() |
Triggers a new note. |
change_pan() |
Changes panning of voices (stereo balance). |
change_tune() |
Changes the tuning of voices. |
change_vol() |
Changes the volume of voices. |
change_cutoff() |
Changes filter cutoff frequency of voices. |
change_reso() |
Changes filter resonance of voices. |
event_status() |
Checks and returns whether a particular note is still alive. |
set_controller() |
Creates a MIDI control change event. |
ignore_event() |
Drops the given event. |
ignore_controller() |
Drops the given MIDI control change event. |
note_off() |
Releases the requested note. |
set_event_mark() |
Adds an event to an event group. |
delete_event_mark() |
Removes an event from some event group. |
by_marks() |
Returns all events of an event group. |
Sampler format specific functions, dedicated to the individual features of the GigaStudio format engine.
Function | Description |
---|---|
gig_set_dim_zone() |
Changes the currently active dimension zone. |
These are the built-in variables and built-in constants available with the NKSP realt-time instrument script language.
Most fundamental NKSP built-in variables, independent from any purpose of being used in a sampler.
Variable | Description |
---|---|
$KSP_TIMER |
Preserved for compatiblity reasons with KSP, returns the same value
as $NKSP_REAL_TIMER (refer to the latter for details).
Note that KSP's reset_ksp_timer() function is not available with
NKSP. However when calculating time differences between two time
stamps taken with $NKSP_REAL_TIMER , calling such a reset
function is not required, because the underlying clock does not stop
when it reached its value limit (which happens every 71 minutes), instead the clock
will automatically restart from zero and the calculated time difference
even between such transitions will reflect correct durations. |
$NKSP_PERF_TIMER |
Returns the current performance time stamp (in microseconds) of the
script running. You may read this variable from time to time to take
time stamps which can be used to calculate the time difference
(in microseconds) which elapsed between them. A performance time
stamp is based on the script's actual CPU execution time. So the
internal clock which is used for generating such time stamps is only
running forward if the respective script is actually executed by the
CPU. Whenever your script is not really executed by the CPU (i.e. because
your script got suspended by a wait() call or got forcely suspended due to
real-time constraints, or when the entire sampler application got suspended
by the OS for other applications or OS tasks) then the underlying internal
clock is paused as well.
$ENGINE_UPTIME instead, which is
also safe for offline bounces.
$NKSP_REAL_TIMER and
$NKSP_PERF_TIMER will actually return the same value. So the
difference between them is not implemented for all systems at the moment.
|
$NKSP_REAL_TIMER |
Returns the current time stamp in reality (in microseconds). You may
read this variable from time to time to take
time stamps which can be used to calculate the time difference
(in microseconds) which elapsed between them. A "real" time
stamp is based on an internal clock which constantly proceeds, so this
internal clock also continues counting while your script is either suspended
(i.e. because your script got suspended by a wait() call or got forcely
suspended due to real-time constraints) and it also continues counting
even if the entire sampler application got suspended by the OS (i.e. to
execute other applications for multi-tasking or to perform OS tasks).
$ENGINE_UPTIME instead, which is
also safe for offline bounces.
$NKSP_REAL_TIMER and
$NKSP_PERF_TIMER will actually return the same value. So the
difference between them is not implemented for all systems at the moment.
|
Basic sampler related built-in variables and constants, independent from a particular sampler format or sampler engine.
Variable | Description |
---|---|
$CC_NUM |
MIDI controller number that caused the controller
handler to be executed (only useful in the context of a
controller handler). |
%CC[] |
Provides access to all current MIDI controller values. This can be
used in any context. Use the respective MIDI controller number as
index to this integer array variable. For instance %CC[1]
would give you the current value of the modulation wheel.
|
$EVENT_ID |
ID of the event that caused the current event handler to be executed. In
the context of a note handler this would be the event
ID of the note, within a controller handler it would
be the controller event ID, etc. |
$EVENT_NOTE |
MIDI note number that caused a note related
handler to be executed (only useful in the context of a
note or release handler). |
$EVENT_VELOCITY |
MIDI velocity value of the note that caused that note related
handler to be executed (only useful in the context of a
note or release handler). |
$EVENT_STATUS_INACTIVE |
Constant bit flag used as possible return value by
event_status() in case the requested
note is not "alive". |
$EVENT_STATUS_NOTE_QUEUE |
Constant bit flag used as possible return value by
event_status() in case the requested
note is still "alive". |
%KEY_DOWN[] |
This can be used in any context to check whether a certain MIDI
key is currently pressed down. Use the respective MIDI note number
as index to this array variable (see also event_status() ). |
$VCC_MONO_AT |
Constant identifying the MIDI monophonic aftertouch controller (also
called
MIDI channel pressure
). This is somewhat different than in the MIDI standard. With
NKSP aftertouch is handled like an additional "regular" MIDI CC controller.
Therefore use
%CC[$VCC_MONO_AT] to obtain the current aftertouch value
in the context of a controller event handler.
|
$VCC_PITCH_BEND |
Constant identifying the pitch bend wheel controller.
This is somewhat different than in the MIDI standard. With
NKSP pitch bend is handled like an additional "regular" MIDI CC controller.
Therefore use
%CC[$VCC_PITCH_BEND] to obtain the current pitch bend wheel value
in the context of a controller event handler. |
$MARK_1 to $MARK_28 |
Used to select one of the available 28 event groups.
See set_event_mark() for details. |
$ENGINE_UPTIME |
Returns the current time stamp (in milliseconds) for being used in a musical context. You may read this variable from time to time to take time stamps which can be used to calculate the time difference (in milliseconds) which elapsed between them. These timing values are based on the internal sample rate and thus it can safely be used to perform musical timing related tasks in your scripts. Especially your script will also continue to behave correctly when an offline bounce of a song is performed. |
Sampler format specific built-in variables and constants, dedicated to the individual features of the GigaStudio format engine.
Variable | Description |
---|---|
$GIG_DIM_CHANNEL |
Constant that identifies the stereo dimension. |
$GIG_DIM_LAYER |
Constant that identifies the layer dimension. |
$GIG_DIM_VELOCITY |
Constant that identifies the velocity dimension. |
$GIG_DIM_AFTERTOUCH |
Constant that identifies the aftertouch dimension. |
$GIG_DIM_RELEASE |
Constant that identifies the release trigger dimension. |
$GIG_DIM_KEYBOARD |
Constant that identifies the keyboard position dimension. |
$GIG_DIM_ROUNDROBIN" |
Constant that identifies the round robin dimension. |
$GIG_DIM_RANDOM |
Constant that identifies the random dimension. |
$GIG_DIM_SMARTMIDI |
Constant that identifies the start MIDI dimension (a.k.a iMIDI rules). |
$GIG_DIM_ROUNDROBINKEY |
Constant that identifies the round robin key dimension. |
$GIG_DIM_MODWHEEL |
Constant that identifies the modulation wheel dimension. |
$GIG_DIM_SUSTAIN |
Constant that identifies the sustain pedal dimension (a.k.a. hold pedal). |
$GIG_DIM_PORTAMENTO |
Constant that identifies the portamento MIDI controller dimension. |
$GIG_DIM_SOSTENUTO |
Constant that identifies the sostenuto MIDI controller dimension. |
$GIG_DIM_SOFT |
Constant that identifies the soft pedal dimension. |
$GIG_DIM_BREATH |
Constant that identifies the breath controller dimension. |
$GIG_DIM_FOOT |
Constant that identifies the foot pedal dimension. |
$GIG_DIM_PORTAMENTOTIME |
Constant that identifies the portamento time controller dimension. |
$GIG_DIM_EFFECT1 |
Constant that identifies the effect 1 MIDI controller dimension. |
$GIG_DIM_EFFECT2 |
Constant that identifies the effect 2 MIDI controller dimension. |
$GIG_DIM_EFFECT1DEPTH |
Constant that identifies the effect 1 depth MIDI controller dimension. |
$GIG_DIM_EFFECT2DEPTH |
Constant that identifies the effect 2 depth MIDI controller dimension. |
$GIG_DIM_EFFECT3DEPTH |
Constant that identifies the effect 3 depth MIDI controller dimension. |
$GIG_DIM_EFFECT4DEPTH |
Constant that identifies the effect 4 depth MIDI controller dimension. |
$GIG_DIM_EFFECT5DEPTH |
Constant that identifies the effect 5 depth MIDI controller dimension. |
$GIG_DIM_GENPURPOSE1 |
Constant that identifies the general purpose 1 MIDI controller dimension. |
$GIG_DIM_GENPURPOSE2 |
Constant that identifies the general purpose 2 MIDI controller dimension. |
$GIG_DIM_GENPURPOSE3 |
Constant that identifies the general purpose 3 MIDI controller dimension. |
$GIG_DIM_GENPURPOSE4 |
Constant that identifies the general purpose 4 MIDI controller dimension. |
$GIG_DIM_GENPURPOSE5 |
Constant that identifies the general purpose 5 MIDI controller dimension. |
$GIG_DIM_GENPURPOSE6 |
Constant that identifies the general purpose 6 MIDI controller dimension. |
$GIG_DIM_GENPURPOSE7 |
Constant that identifies the general purpose 7 MIDI controller dimension. |
$GIG_DIM_GENPURPOSE8 |
Constant that identifies the general purpose 8 MIDI controller dimension. |