/[svn]/doc/docbase/instrument_scripts/nksp/reference/01_nksp_reference.html
ViewVC logotype

Contents of /doc/docbase/instrument_scripts/nksp/reference/01_nksp_reference.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2944 - (show annotations) (download) (as text)
Wed Jul 13 16:52:58 2016 UTC (3 years, 4 months ago) by schoenebeck
File MIME type: text/html
File size: 19434 byte(s)
* NKSP: Added built-in script variables $KSP_TIMER, $NKSP_PERF_TIMER,
  $NKSP_REAL_TIMER and $ENGINE_UPTIME.

1 <html>
2 <head>
3 <meta name="author" content="Christian Schoenebeck">
4 <title>NKSP Reference</title>
5 <urlpath>Reference</urlpath>
6 <navpath>Reference Manual</navpath>
7 <meta name="description" content="Reference documentation of the NKSP real-time instrument script language.">
8 </head>
9 <body>
10 <h1>NKSP Reference</h1>
11 <p>
12 This document gives you an overview of all built-in functions and built-in
13 variables provided by the NKSP real-time instrument script language.
14 </p>
15
16 <h2>Built-In Functions</h2>
17 <p>
18 These are the built-in functions available with the NKSP realt-time
19 instrument script language.
20 </p>
21
22 <h3>Core Language Functions</h3>
23 <p>
24 Most fundamental NKSP functions, independent from any purpose of being used in a sampler.
25 </p>
26 <table>
27 <tr>
28 <th>Function</th> <th>Description</th>
29 </tr>
30 <tr>
31 <td><code lang="nksp">message()</code></td>
32 <td>Prints text to the sampler's terminal.</td>
33 </tr>
34 <tr>
35 <td><code>exit()</code></td>
36 <td>Stops execution of the current event handler instance.</td>
37 </tr>
38 <tr>
39 <td><code>wait()</code></td>
40 <td>Pauses execution for a certain amount of time.</td>
41 </tr>
42 <tr>
43 <td><code>abs()</code></td>
44 <td>Calculates the absolute value of a given value.</td>
45 </tr>
46 <tr>
47 <td><code>random()</code></td>
48 <td>Random number generator.</td>
49 </tr>
50 <tr>
51 <td><code>num_elements()</code></td>
52 <td>Returns the size of the requested array variable.</td>
53 </tr>
54 </table>
55
56 <h3>Common Sampler Functions</h3>
57 <p>
58 Basic sampler related functions, independent from a particular sampler
59 format or sampler engine.
60 </p>
61 <table>
62 <tr>
63 <th>Function</th> <th>Description</th>
64 </tr>
65 <tr>
66 <td><code>play_note()</code></td>
67 <td>Triggers a new note.</td>
68 </tr>
69 <tr>
70 <td><code>change_pan()</code></td>
71 <td>Changes panning of voices (stereo balance).</td>
72 </tr>
73 <tr>
74 <td><code>change_tune()</code></td>
75 <td>Changes the tuning of voices.</td>
76 </tr>
77 <tr>
78 <td><code>change_vol()</code></td>
79 <td>Changes the volume of voices.</td>
80 </tr>
81 <tr>
82 <td><code>change_cutoff()</code></td>
83 <td>Changes filter cutoff frequency of voices.</td>
84 </tr>
85 <tr>
86 <td><code>change_reso()</code></td>
87 <td>Changes filter resonance of voices.</td>
88 </tr>
89 <tr>
90 <td><code>event_status()</code></td>
91 <td>Checks and returns whether a particular note is still alive.</td>
92 </tr>
93 <tr>
94 <td><code>set_controller()</code></td>
95 <td>Creates a MIDI control change event.</td>
96 </tr>
97 <tr>
98 <td><code>ignore_event()</code></td>
99 <td>Drops the given event.</td>
100 </tr>
101 <tr>
102 <td><code>ignore_controller()</code></td>
103 <td>Drops the given MIDI control change event.</td>
104 </tr>
105 <tr>
106 <td><code>note_off()</code></td>
107 <td>Releases the requested note.</td>
108 </tr>
109 <tr>
110 <td><code>set_event_mark()</code></td>
111 <td>Adds an event to an event group.</td>
112 </tr>
113 <tr>
114 <td><code>delete_event_mark()</code></td>
115 <td>Removes an event from some event group.</td>
116 </tr>
117 <tr>
118 <td><code>by_marks()</code></td>
119 <td>Returns all events of an event group.</td>
120 </tr>
121 </table>
122
123 <h3>GigaStudio Format Functions</h3>
124 <p>
125 Sampler format specific functions, dedicated to the individual features
126 of the GigaStudio format engine.
127 </p>
128 <table>
129 <tr>
130 <th>Function</th> <th>Description</th>
131 </tr>
132 <tr>
133 <td><code>gig_set_dim_zone()</code></td>
134 <td>Changes the currently active dimension zone.</td>
135 </tr>
136 </table>
137
138 <h2>Built-In Variables</h2>
139 <p>
140 These are the built-in variables and built-in constants available with the
141 NKSP realt-time instrument script language.
142 </p>
143
144 <h3>Core Language Variables</h3>
145 <p>
146 Most fundamental NKSP built-in variables, independent from any purpose of
147 being used in a sampler.
148 </p>
149 <table>
150 <tr>
151 <th>Variable</th> <th>Description</th>
152 </tr>
153 <tr>
154 <td><code>$KSP_TIMER</code></td>
155 <td>Preserved for compatiblity reasons with KSP, returns the same value
156 as <code>$NKSP_REAL_TIMER</code> (refer to the latter for details).
157 Note that KSP's <code>reset_ksp_timer()</code> function is not available with
158 NKSP. However when calculating time differences between two time
159 stamps taken with <code>$NKSP_REAL_TIMER</code>, calling such a reset
160 function is not required, because the underlying clock does not stop
161 when it reached its value limit (which happens every 71 minutes), instead the clock
162 will automatically restart from zero and the calculated time difference
163 even between such transitions will reflect correct durations.</td>
164 </tr>
165 <tr>
166 <td><code>$NKSP_PERF_TIMER</code></td>
167 <td>Returns the current performance time stamp (in microseconds) of the
168 script running. You may read this variable from time to time to take
169 time stamps which can be used to calculate the time difference
170 (in microseconds) which elapsed between them. A performance time
171 stamp is based on the script's actual CPU execution time. So the
172 internal clock which is used for generating such time stamps is only
173 running forward if the respective script is actually executed by the
174 CPU. Whenever your script is not really executed by the CPU (i.e. because
175 your script got suspended by a wait() call or got forcely suspended due to
176 real-time constraints, or when the entire sampler application got suspended
177 by the OS for other applications or OS tasks) then the underlying internal
178 clock is paused as well.
179 <note class="important">
180 You should only use this built-in variable for script development
181 purposes (i.e. for bench marking the performance of your script).
182 You should <b>not</b> use it with your final production sounds!
183 It is not appropriate for being used in a musical context, because
184 when an offline bounce is performed for instance, the musical timing
185 will be completely unrelated to the CPU execution time. Plus using
186 this variable may cause audio drop outs on some systems. In a musical
187 context you should use <code>$ENGINE_UPTIME</code> instead, which is
188 also safe for offline bounces.
189 </note>
190 <note>
191 On some systems <code>$NKSP_REAL_TIMER</code> and
192 <code>$NKSP_PERF_TIMER</code> will actually return the same value. So the
193 difference between them is not implemented for all systems at the moment.
194 </note>
195 </td>
196 </tr>
197 <tr>
198 <td><code>$NKSP_REAL_TIMER</code></td>
199 <td>Returns the current time stamp in reality (in microseconds). You may
200 read this variable from time to time to take
201 time stamps which can be used to calculate the time difference
202 (in microseconds) which elapsed between them. A "real" time
203 stamp is based on an internal clock which constantly proceeds, so this
204 internal clock also continues counting while your script is either suspended
205 (i.e. because your script got suspended by a wait() call or got forcely
206 suspended due to real-time constraints) and it also continues counting
207 even if the entire sampler application got suspended by the OS (i.e. to
208 execute other applications for multi-tasking or to perform OS tasks).
209 <note class="important">
210 You should only use this built-in variable for script development
211 purposes (i.e. for bench marking the performance of your script).
212 You should <b>not</b> use it with your final production sounds!
213 It is not appropriate for being used in a musical context, because
214 when an offline bounce is performed for instance, the musical timing
215 will be completely unrelated to the CPU execution time. Plus using
216 this variable may cause audio drop outs on some systems. In a musical
217 context you should use <code>$ENGINE_UPTIME</code> instead, which is
218 also safe for offline bounces.
219 </note>
220 <note>
221 On some systems <code>$NKSP_REAL_TIMER</code> and
222 <code>$NKSP_PERF_TIMER</code> will actually return the same value. So the
223 difference between them is not implemented for all systems at the moment.
224 </note>
225 </td>
226 </tr>
227 </table>
228
229 <h3>Common Sampler Variables</h3>
230 <p>
231 Basic sampler related built-in variables and constants, independent from a
232 particular sampler format or sampler engine.
233 </p>
234 <table>
235 <tr>
236 <th>Variable</th> <th>Description</th>
237 </tr>
238 <tr>
239 <td><code>$CC_NUM</code></td>
240 <td>MIDI controller number that caused the <code>controller</code>
241 handler to be executed (only useful in the context of a
242 <code>controller</code> handler).</td>
243 </tr>
244 <tr>
245 <td><code>%CC[]</code></td>
246 <td>Provides access to all current MIDI controller values. This can be
247 used in any context. Use the respective MIDI controller number as
248 index to this integer array variable. For instance <code>%CC[1]</code>
249 would give you the current value of the modulation wheel.
250 </td>
251 </tr>
252 <tr>
253 <td><code>$EVENT_ID</code></td>
254 <td>ID of the event that caused the current event handler to be executed. In
255 the context of a <code>note</code> handler this would be the event
256 ID of the note, within a <code>controller</code> handler it would
257 be the controller event ID, etc.</td>
258 </tr>
259 <tr>
260 <td><code>$EVENT_NOTE</code></td>
261 <td>MIDI note number that caused a note related
262 handler to be executed (only useful in the context of a
263 <code>note</code> or <code>release</code> handler).</td>
264 </tr>
265 <tr>
266 <td><code>$EVENT_VELOCITY</code></td>
267 <td>MIDI velocity value of the note that caused that note related
268 handler to be executed (only useful in the context of a
269 <code>note</code> or <code>release</code> handler).</td>
270 </tr>
271 <tr>
272 <td><code>$EVENT_STATUS_INACTIVE</code></td>
273 <td>Constant bit flag used as possible return value by
274 <code>event_status()</code> in case the requested
275 note is not "alive".</td>
276 </tr>
277 <tr>
278 <td><code>$EVENT_STATUS_NOTE_QUEUE</code></td>
279 <td>Constant bit flag used as possible return value by
280 <code>event_status()</code> in case the requested
281 note is still "alive".</td>
282 </tr>
283 <tr>
284 <td><code>%KEY_DOWN[]</code></td>
285 <td>This can be used in any context to check whether a certain MIDI
286 key is currently pressed down. Use the respective MIDI note number
287 as index to this array variable (see also <code>event_status()</code>).</td>
288 </tr>
289 <tr>
290 <td><code>$VCC_MONO_AT</code></td>
291 <td>Constant identifying the MIDI monophonic aftertouch controller (also
292 called <i title="Amount of force on held-down key.">
293 MIDI channel pressure
294 </i>). This is somewhat different than in the MIDI standard. With
295 NKSP aftertouch is handled like an additional "regular" MIDI CC controller.
296 Therefore use
297 <code>%CC[$VCC_MONO_AT]</code> to obtain the current aftertouch value
298 in the context of a <code>controller</code> event handler.
299 </td>
300 </tr>
301 <tr>
302 <td><code>$VCC_PITCH_BEND</code></td>
303 <td>Constant identifying the pitch bend wheel controller.
304 This is somewhat different than in the MIDI standard. With
305 NKSP pitch bend is handled like an additional "regular" MIDI CC controller.
306 Therefore use
307 <code>%CC[$VCC_PITCH_BEND]</code> to obtain the current pitch bend wheel value
308 in the context of a <code>controller</code> event handler.</td>
309 </tr>
310 <tr>
311 <td><code>$MARK_1</code> to <code>$MARK_28</code></td>
312 <td>Used to select one of the available 28 event groups.
313 See <code>set_event_mark()</code> for details.</td>
314 </tr>
315 <tr>
316 <td><code>$ENGINE_UPTIME</code></td>
317 <td>Returns the current time stamp (in milliseconds) for being
318 used in a musical context. You may read this variable from time to time
319 to take time stamps which can be used to calculate the time difference
320 (in milliseconds) which elapsed between them. These timing values are
321 based on the internal sample rate and thus it can safely be used to
322 perform musical timing related tasks in your scripts. Especially
323 your script will also continue to behave correctly when an offline bounce
324 of a song is performed.
325 </td>
326 </tr>
327 </table>
328
329 <h3>GigaStudio Format Variables</h3>
330 <p>
331 Sampler format specific built-in variables and constants, dedicated to the
332 individual features of the GigaStudio format engine.
333 </p>
334 <table>
335 <tr>
336 <th>Variable</th> <th>Description</th>
337 </tr>
338 <tr>
339 <td><code>$GIG_DIM_CHANNEL</code></td>
340 <td>Constant that identifies the <i>stereo dimension</i>.</td>
341 </tr>
342 <tr>
343 <td><code>$GIG_DIM_LAYER</code></td>
344 <td>Constant that identifies the <i>layer dimension</i>.</td>
345 </tr>
346 <tr>
347 <td><code>$GIG_DIM_VELOCITY</code></td>
348 <td>Constant that identifies the <i>velocity dimension</i>.</td>
349 </tr>
350 <tr>
351 <td><code>$GIG_DIM_AFTERTOUCH</code></td>
352 <td>Constant that identifies the <i>aftertouch dimension</i>.</td>
353 </tr>
354 <tr>
355 <td><code>$GIG_DIM_RELEASE</code></td>
356 <td>Constant that identifies the <i>release trigger dimension</i>.</td>
357 </tr>
358 <tr>
359 <td><code>$GIG_DIM_KEYBOARD</code></td>
360 <td>Constant that identifies the <i>keyboard position dimension</i>.</td>
361 </tr>
362 <tr>
363 <td><code>$GIG_DIM_ROUNDROBIN"</code></td>
364 <td>Constant that identifies the <i>round robin dimension</i>.</td>
365 </tr>
366 <tr>
367 <td><code>$GIG_DIM_RANDOM</code></td>
368 <td>Constant that identifies the <i>random dimension</i>.</td>
369 </tr>
370 <tr>
371 <td><code>$GIG_DIM_SMARTMIDI</code></td>
372 <td>Constant that identifies the <i>start MIDI dimension</i> (a.k.a iMIDI rules).</td>
373 </tr>
374 <tr>
375 <td><code>$GIG_DIM_ROUNDROBINKEY</code></td>
376 <td>Constant that identifies the <i>round robin key dimension</i>.</td>
377 </tr>
378 <tr>
379 <td><code>$GIG_DIM_MODWHEEL</code></td>
380 <td>Constant that identifies the <i>modulation wheel dimension</i>.</td>
381 </tr>
382 <tr>
383 <td><code>$GIG_DIM_SUSTAIN</code></td>
384 <td>Constant that identifies the <i>sustain pedal dimension</i> (a.k.a. hold pedal).</td>
385 </tr>
386 <tr>
387 <td><code>$GIG_DIM_PORTAMENTO</code></td>
388 <td>Constant that identifies the <i>portamento MIDI controller dimension</i>.</td>
389 </tr>
390 <tr>
391 <td><code>$GIG_DIM_SOSTENUTO</code></td>
392 <td>Constant that identifies the <i>sostenuto MIDI controller dimension</i>.</td>
393 </tr>
394 <tr>
395 <td><code>$GIG_DIM_SOFT</code></td>
396 <td>Constant that identifies the <i>soft pedal dimension</i>.</td>
397 </tr>
398 <tr>
399 <td><code>$GIG_DIM_BREATH</code></td>
400 <td>Constant that identifies the <i>breath controller dimension</i>.</td>
401 </tr>
402 <tr>
403 <td><code>$GIG_DIM_FOOT</code></td>
404 <td>Constant that identifies the <i>foot pedal dimension</i>.</td>
405 </tr>
406 <tr>
407 <td><code>$GIG_DIM_PORTAMENTOTIME</code></td>
408 <td>Constant that identifies the <i>portamento time controller dimension</i>.</td>
409 </tr>
410 <tr>
411 <td><code>$GIG_DIM_EFFECT1</code></td>
412 <td>Constant that identifies the <i>effect 1 MIDI controller dimension</i>.</td>
413 </tr>
414 <tr>
415 <td><code>$GIG_DIM_EFFECT2</code></td>
416 <td>Constant that identifies the <i>effect 2 MIDI controller dimension</i>.</td>
417 </tr>
418 <tr>
419 <td><code>$GIG_DIM_EFFECT1DEPTH</code></td>
420 <td>Constant that identifies the <i>effect 1 depth MIDI controller dimension</i>.</td>
421 </tr>
422 <tr>
423 <td><code>$GIG_DIM_EFFECT2DEPTH</code></td>
424 <td>Constant that identifies the <i>effect 2 depth MIDI controller dimension</i>.</td>
425 </tr>
426 <tr>
427 <td><code>$GIG_DIM_EFFECT3DEPTH</code></td>
428 <td>Constant that identifies the <i>effect 3 depth MIDI controller dimension</i>.</td>
429 </tr>
430 <tr>
431 <td><code>$GIG_DIM_EFFECT4DEPTH</code></td>
432 <td>Constant that identifies the <i>effect 4 depth MIDI controller dimension</i>.</td>
433 </tr>
434 <tr>
435 <td><code>$GIG_DIM_EFFECT5DEPTH</code></td>
436 <td>Constant that identifies the <i>effect 5 depth MIDI controller dimension</i>.</td>
437 </tr>
438 <tr>
439 <td><code>$GIG_DIM_GENPURPOSE1</code></td>
440 <td>Constant that identifies the <i>general purpose 1 MIDI controller dimension</i>.</td>
441 </tr>
442 <tr>
443 <td><code>$GIG_DIM_GENPURPOSE2</code></td>
444 <td>Constant that identifies the <i>general purpose 2 MIDI controller dimension</i>.</td>
445 </tr>
446 <tr>
447 <td><code>$GIG_DIM_GENPURPOSE3</code></td>
448 <td>Constant that identifies the <i>general purpose 3 MIDI controller dimension</i>.</td>
449 </tr>
450 <tr>
451 <td><code>$GIG_DIM_GENPURPOSE4</code></td>
452 <td>Constant that identifies the <i>general purpose 4 MIDI controller dimension</i>.</td>
453 </tr>
454 <tr>
455 <td><code>$GIG_DIM_GENPURPOSE5</code></td>
456 <td>Constant that identifies the <i>general purpose 5 MIDI controller dimension</i>.</td>
457 </tr>
458 <tr>
459 <td><code>$GIG_DIM_GENPURPOSE6</code></td>
460 <td>Constant that identifies the <i>general purpose 6 MIDI controller dimension</i>.</td>
461 </tr>
462 <tr>
463 <td><code>$GIG_DIM_GENPURPOSE7</code></td>
464 <td>Constant that identifies the <i>general purpose 7 MIDI controller dimension</i>.</td>
465 </tr>
466 <tr>
467 <td><code>$GIG_DIM_GENPURPOSE8</code></td>
468 <td>Constant that identifies the <i>general purpose 8 MIDI controller dimension</i>.</td>
469 </tr>
470 </table>
471
472 </body>
473 </html>

  ViewVC Help
Powered by ViewVC