Author: Sander
Script Version: 1
Minimum CoyoteMIDI Build: 553
// Get the list of keystrokes from the input field in the translation.
$hotkeys = (split ($parameters Keystrokes) ",")
// Define the max value possible based on the midi event
$max = 127
if ($trigger midievent) == pitchbend
$max = 16383
// This calculates which hotkey the current fader position corresponds with
$choice = (round ($trigger rawvalue) / $max * ((count $hotkeys) - 1)) + 1
// If the same hotkey as last time is being repeated again, we add a little cooldown to avoid spam-repeating the same hotkey over and over.
if (%segmented_hotkeys_last_choice ($trigger translationid)) == $choice && ((time) - (%segmented_hotkeys_last_time ($trigger translationid))) < ($parameters Cooldown)
return
// Store which hotkey was last executed and when.
%segmented_hotkeys_last_choice ($trigger translationid) = $choice
%segmented_hotkeys_last_time ($trigger translationid) = (time)
// Finally, simulate the hotkey.
key stroke (replace (trim ($hotkeys $choice)) " " ",")
// Create the required map variables
event scriptsloaded
%segmented_hotkeys_last_choice new map
%segmented_hotkeys_last_time new map
// Add the keystrokes input field on the translation UI.
event uirefreshed
translationparameter Keystrokes (textbox Keys "The list of keystrokes to spread out across segments on the MIDI input. Multiple keys inside a single keystroke should be separated by a space, while each keystroke should be separated by a comma." default 0.7)
translationparameter Cooldown (numberbox "Debounce Cooldown" "The amount of time in seconds for which a given keystroke will not be able to be repeated after itself." 1 0.3 true 0 100 0.1)
15 downloads