Is there any way to "kill" a taskfunc instance?

Hi. Amateur ksp programmer here using SublimeKSP, and I have hit a roadblock in a piano script I am doing...
In order to script re-pedal events (ie, rapid pedal press after release that "catches" a sustaining note and maintains it instead of fast decaying), I have scripted the normal release decay as a succession of 4 fast tcm.wait() and fade_out commands that create an exponential decay of the sample (instead of the non-piano like linear decay of the regular fade_out...). Those tcm.wait and fade_outs are set inside a taskfunc that is triggered for each note release. So far so good and the release decays sound as good as release samples.
However, for scripting the re-pedalling I need to stop that taskfunc whenever there is a change in the #CC value of the pedal, so that a new faster or slower fade_out() command overrides the ongoing fade_out. However, I cannot find a way to "kill" a particular taskfunc... I am storing the taskfunc CALLBACK_ID in a array and I use that information to stop_wait(CALLBACK_ID, 1) the remaining tcm.wait() commands in that instance, but that does not block the remaining fade_outs from being executed. Is there something like exit(CALLBACK_ID)? Is there a work-around I am not thinking about? Any help is appreciated...
Comments
-
Replying to my own discussion... I will try to abort the instance by having it check a global variable (an array that acts as flag for each active instance of the taskfunc). So, before executing the next tcm.wait() within the taskfunc, it will query the flag variable and if true it will execute a exit() command. Not elegant, but it should work, although it is a lot of checking and doublechecking... An assignable exit(callback_id) would be far better.
All additional suggestions and criticisms are welcome...
0 -
Should either ask for this to be moved to Scripting Workshop, or repost it there so it gets better attention.
1 -
Thanks... Problems of first time poster...
0 -
In case someone stumbles upon this discussion, my solution worked as intended. In fact, I ended up using the callback_id as a "flag"... Everytime a note calls the decay taskfunc() the callback_id is stored in a array[note]. Inside the taskfunc() there are 4 tcm.wait() commands that interrupt 4 fade-outs of increasing length. All it was needed was to check, before each tcm.wait(), if the callback_id of that note remained the same as the callback itself. If not, then it means that a newer instance was triggered and in that case the callback should be aborted using the exit command...
0 -
Do note that using exit in taskfuncs is not entirely clean and has unforeseen outcomes.
0 -
ED: Thanks for the heads-up, but I am afraid that the concept of TCM memory pointers is beyond my skills... Should I put a call to the "TCM epilogue" (whatever that is...) before the taskfunc exit? My taskfunc is rather simple and contains only a few lines of code: a fade_out command followed by a conditional wait() or exit, then another fade_out and another check for wait or exit, and then a third similar block. Should I worry? What should I be looking for? Execution error or abnormal notes?
0
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 62 NI News
- 788 Tech Talks
- 4.1K Native Access
- 16.6K Komplete
- 2K Komplete General
- 4.3K Komplete Kontrol
- 5.7K Kontakt
- 1.6K Reaktor
- 380 Battery 4
- 849 Guitar Rig & FX
- 429 Massive X & Synths
- 1.3K Other Software & Hardware
- 5.8K Maschine
- 7.3K Traktor
- 7.3K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators