So I have some polyphonic variables that modulate stuff (like tremolo and vibrato) and which speed is dependent upon a $counter variable in a while loop. Something like this :
on init
declare polyphonic $counter
end on
on release
while (1 > 0)
$counter := $counter + 1
message($counter)
wait(10000)
end while
end on
The only problem is: if I play a note with the sustain pedal on, release the note and then release the sustain pedal, the counter will increase twice as fast, because Kontakt triggers 2 release callbacks with the same $EVENT_ID : one for the Note Off event and another for the sustain pedal release. Therefore, my tremolo and vibrato speed go twice as fast.
Is there any way I can get around this without having to change the CC64 parameters in the Instrument options? I want to still be able to use my sustain pedal for sustaining sounds and for other purposes as well.
Maybe something with the listener callback? I'm still unsure as to how I would do it though...
Thanks!