User Submitted CoyoteScript

Segmented Keystrokes

Author: Sander

Script Version: 1

Minimum CoyoteMIDI Build: 553

Lets you assign a series of different hotkeys to the same MIDI input, automatically assigning a unique segment of the MIDI control values to each hotkey.
For example, you can assign “CTRL 1, CTRL 2, CTRL3, CTRL4” to ControlChange 1, which will cause “CTRL 1” to be assigned when the ControlChange 1 value enters the range of 0 to 31, “CTRL 2” to the range of 32 to 63, and so on.

This script adds the following translation parameters:

Keystrokes: 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 combination should be separated by a comma.

Debounce Cooldown: The amount of time in seconds for which a given keystroke will not be able to repeat after itself.
				
					// 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