There are two adjustments I've been looking to make to a keyswitch note fadeout script that I've been working on for an instrument.:
- I'd like for the keyswitch to ignore any notes that I still have my fingers held down on, and to only fade out/mute the notes that I've taken my fingers off of.
- I'd like for the keyswitch to activate essentially from the initial note on event only (if that makes any sense). So if I were to play a note, then release my finger, the keyswitch would effectively fade out/mute the released notes, yet if I were to keep the keyswitch held down, the script would still allow for me to play any consecutive notes without fading out. Essentially making the initial triggering of the keyswitch the gate in which the fadeout is activated, as oppose to it being during the entire duration that the keyswitch is held down.
Side Note: The keyswitch uses C-1 as its trigger to fade out any resonating notes while or after a note has been played. The ADSR release envelope should also be turned all the way up for the script to work as intended
The Code:
on init
declare $count
declare $fade_out
declare ui_knob $fade_time(10000,1000000,100000)
set_text($fade_time,"Length")
make_persistent($fade_time)
move_control($fade_time,1,1)
declare const $KEY_SWITCH := 12
set_key_color(12,$KEY_COLOR_RED)
end on
on note
if ($EVENT_NOTE=$KEY_SWITCH)
fade_out($ALL_EVENTS,$fade_time,0)
$fade_out := 0
end if
end on
...
I am not the best with scripting, so any help with this would be greatly appreciated!