Author: Sander
Script Version: 6
Minimum CoyoteMIDI Build: 664
enforcetrigger translation
// Get the CC we want to manipulate
$cc = ($parameters CC)
// Get the direction we want to move the CC in
$direction = ($parameters direction)
// Get the amount we want to move the CC with
$amount = ($parameters amount)
// Get whether the script should send MIDI out
$out = ($parameters out)
// Run the change handler
runscript default change_value cc:$cc,direction:$direction,out:$out,trigger:$trigger,amount:$amount
script repeat
enforcetrigger translation
// Get the CC we want to manipulate
$cc = ($parameters CC)
// Get the direction we want to move the CC in
$direction = ($parameters direction)
// Get the amount we want to move the CC with
$amount = ($parameters amount)
// Get whether the script should send MIDI out
$out = ($parameters out)
// Make sure the translation was triggered by keys being held down
if !$trigger || $trigger !contains keys
messagebox "This script is designed to run from translations triggered by key presses!"
return
$keys = ($trigger keys)
// Repeat running the change script while the key is held down
while true
// If any of the keys aren't held down anymore, stop repeating
foreach $key in $keys
if !(keystate $key)
return
// run the change handler
runscript default change_value cc:$cc,direction:$direction,out:$out,trigger:$trigger,amount:$amount
wait ($parameters delay)
// The subscript that actually handles the change logic. This is designed to also be able to be called from other scripts so try not to change the name or variables.
script change_value hidden
// Make sure this CC has a value in the map of CCs this script is manipulating
if %virtual_cc_manipulator_values !contains $cc
%virtual_cc_manipulator_values $cc = 0
// Get the last set value for this CC
$value = (%virtual_cc_manipulator_values $cc)
// If the direction is up, increase the value
if $direction == Up
$value = (min 127 ($value + $amount))
// If the direction is down, decrease the value
else if $direction == Down && $value > 0
$value = (max 0 ($value - $amount))
// if the direction is exact, we just set the value to the new amount
else if $direction == Exact
$value = $amount
// If the direction is input, we copy the value from the input and use that as the new amount.
else if $direction == Input
if !$trigger || $trigger !contains rawvalue
messagebox "The translation needs to be triggered by a valid MIDI event when using the 'input' mode!" "Virtual CC Sender Error"
return
$value = ($trigger rawvalue)
// Update the last set value to the map
%virtual_cc_manipulator_values $cc = $value
// Send the MIDI event to the MIDI out devices if applicable
if $out
midi controlchange $cc $value
// Declare the map holding the virtual CC values
event scriptsloaded
%virtual_cc_manipulator_values new map
// Register the input fields to be shown in a translation using the script
event uirefreshed
translationparameter CC (numberbox "CC" "The CC number to change the value of." 1 default false 0 127 1)
translationparameter direction (combobox Change "The type of change to apply to the CC value." Up,Down,Exact,Input Up 0.5)
translationparameter amount (numberbox "Amount" "The amount to increase or decrease the CC value with." 1 default false 0 127 1)
translationparameter delay (numberbox "Delay" "The amount of time in seconds in between each change while the input keys are held down." 0.1 default true 0 default 0.1) repeat
translationparameter out (checkbox "Send Out" "Whether the CC value should be sent back out of CoyoteMIDI's MIDI outputs. If unchecked, this will only update the internal value that the script stores, but not send a new event out." true)
21 downloads