|
From: Christian S. <sch...@li...> - 2016-07-09 15:08:06
|
Any Kontakt users out there?
As I've just been working on adding synthesis parameter functions to our
instrument script engine, I wondered how endless loops are usually hanndled
with Kontakt KSP scripts?
Let's assume you want to implement a simple stuttering effect by using an
instrument script, you could do it like with the following one:
on note
while (1)
wait(200000)
change_vol($EVENT_ID, -20000)
wait(200000)
change_vol($EVENT_ID, 0)
end while
end on
This works, however the problem is that this script will run forever, even if
your note and/or voices are long dead and gone. So since execution of this
particular script will *never* stop, this is certainly not what you want to
end with. How do Kontakt KSP script authors usually handle this?
Intuitively the right way to fix the upper script, would be something like
this:
on note
while (1)
wait(200000)
if (note_is_gone($EVENT_ID))
exit()
end if
change_vol($EVENT_ID, -20000)
wait(200000)
if (note_is_gone($EVENT_ID))
exit()
end if
change_vol($EVENT_ID, 0)
end while
end on
But as far as I can see it, Kontakt does not provide a built-in function (like
"note_is_gone()" in the latter pseudo solution) for checking whether
notes/voices are gone, is there any?
Another "solution" would be to force quitting execution of such an endless
script by the script engine itself as soon as the respective notes/voices are
gone. But IMO auto killing scripts would not be a desirable solution either,
because a script author might intentionally i.e. want to trigger new voices
with play_note() after the original voices are gone (i.e. for delay effects).
So IMO it should be up to the script author to define when his endless loops
should stop and when not.
Anybody?
BTW, these are the 3 new NKSP functions just been added & implemented:
http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/change_vol_function/
http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/change_tune_function/
http://doc.linuxsampler.org/Instrument_Scripts/NKSP_Language/Reference/change_pan_function/
CU
Christian
|