--- doc/docbase/instrument_scripts/nksp/reference/01_nksp_reference.html 2015/04/26 20:54:00 2732 +++ doc/docbase/instrument_scripts/nksp/reference/01_nksp_reference.html 2017/04/21 19:45:29 3121 @@ -28,7 +28,19 @@ Function Description - message() + dec() + Decrements the passed integer variable by one. + + + inc() + Increments the passed integer variable by one. + + + in_range() + Checks whether a value is between two other values. + + + message() Prints text to the sampler's terminal. @@ -40,6 +52,10 @@ Pauses execution for a certain amount of time. + stop_wait() + Resumes execution of a suspended script callback. + + abs() Calculates the absolute value of a given value. @@ -48,9 +64,25 @@ Random number generator. + min() + Calculates the minimum value of two given values. + + + max() + Calculates the maximum value of two given values. + + num_elements() Returns the size of the requested array variable. + + sh_left() + Calculates a left bit shifted value. + + + sh_right() + Calculates a right bit shifted value. +

Common Sampler Functions

@@ -67,6 +99,58 @@ 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. + + + change_attack() + Modifies the attack time of voices. + + + change_decay() + Modifies the decay time of voices. + + + change_release() + Modifies the release time of voices. + + + change_amp_lfo_depth() + Modifies the amplitude LFO depth. + + + change_amp_lfo_freq() + Modifies the amplitude LFO frequency. + + + change_pitch_lfo_depth() + Modifies the pitch LFO depth. + + + change_pitch_lfo_freq() + Modifies the pitch LFO frequency. + + + event_status() + Checks and returns whether a particular note is still alive. + + set_controller() Creates a MIDI control change event. @@ -116,7 +200,131 @@ These are the built-in variables and built-in constants available with the NKSP realt-time instrument script language.

- + +

Core Language Variables

+

+ Most fundamental NKSP built-in variables, independent from any purpose of + being used in a sampler. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Variable Description
$KSP_TIMERPreserved 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_TIMERReturns 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. + + You should only use this built-in variable for script development + purposes (i.e. for bench marking the performance of your script). + You should not use it with your final production sounds! + It is not appropriate for being used in a musical context, because + when an offline bounce is performed for instance, the musical timing + will be completely unrelated to the CPU execution time. Plus using + this variable may cause audio drop outs on some systems. In a musical + context you should use $ENGINE_UPTIME instead, which is + also safe for offline bounces. + + + On some systems $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_TIMERReturns 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). + + You should only use this built-in variable for script development + purposes (i.e. for bench marking the performance of your script). + You should not use it with your final production sounds! + It is not appropriate for being used in a musical context, because + when an offline bounce is performed for instance, the musical timing + will be completely unrelated to the CPU execution time. Plus using + this variable may cause audio drop outs on some systems. In a musical + context you should use $ENGINE_UPTIME instead, which is + also safe for offline bounces. + + + On some systems $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. + +
$NI_CALLBACK_IDReflects the current event handler instance's unique callback ID. + For the same event type there may be more than + one event handler instances running. Each one of them has + its own callback ID. You can get the current event handler + instance's callback ID by reading this built-in variable.
$NI_CALLBACK_TYPEReflects the event type of the current event handler. This variable + may reflect one of the following built-in constants: + $NI_CB_TYPE_INIT, $NI_CB_TYPE_NOTE, + $NI_CB_TYPE_RELEASE, $NI_CB_TYPE_CONTROLLER.
$NI_CB_TYPE_INITBuilt-in constant reflecting an init event handler type.
$NI_CB_TYPE_NOTEBuilt-in constant reflecting a note event handler type.
$NI_CB_TYPE_RELEASEBuilt-in constant reflecting a release event handler type.
$NI_CB_TYPE_CONTROLLERBuilt-in constant reflecting a controller event handler type.
$NKSP_IGNORE_WAITIf this boolean built-in variable is 1 then all calls of your + event handler instance to function wait() will be ignored. + This may for example be the case if another event handler instance + resumed your paused script by calling stop_wait() and + passing 1 to the 2nd argument of that function.
+

Common Sampler Variables

Basic sampler related built-in variables and constants, independent from a @@ -127,6 +335,22 @@ Variable Description + %ALL_EVENTS + + Note IDs of all currently active notes of the current sampler part (a.k.a. sampler channel). + This may be passed to many built-in functions like note_off(). + This array variable only contains IDs of notes which were launched due + to MIDI note-on events. This variable does not contain IDs of child notes + (i.e. notes which were launched programmatically by calling play_note()). + + In contrast to KSP this variable is an integer array type, whereas KSP's + pendent of this built-in variable is an integer constant (scalar) called + $ALL_EVENTS. Using the latter with NKSP will cause a + parser warning, the behavior will be the same though. + + + + $CC_NUM MIDI controller number that caused the controller handler to be executed (only useful in the context of a @@ -160,10 +384,22 @@ 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. + as index to this array variable (see also event_status()). $VCC_MONO_AT @@ -183,7 +419,7 @@ 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 aftertouch value + %CC[$VCC_PITCH_BEND] to obtain the current pitch bend wheel value in the context of a controller event handler. @@ -191,6 +427,18 @@ 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. + +

GigaStudio Format Variables