Author: Sander
Script Version: 2
Minimum CoyoteMIDI Build: 771
// default script, volume by MIDI value
script default
// if the configured hotkey for ignoring the input trigger is pressed
if ($parameters IgnoreKey) && (keystate ($parameters IgnoreKey))
return
// Get the target process from the parameters
$target = (runscript default get_target parameters:$parameters)
// Figure out if the max MIDI value for this event is 127 or 16383 (pitchbend)
$max = 127
if ($trigger midievent) == pitchbend
$max = 16383
// convert the 0-127 or 0-16383 scale from the MIDI event to a 0-100 scale for setvolume
$volume = (round ($trigger rawvalue) / $max * 100)
// set the volume
runscript default set_volume volume:$volume,target:$target
// Increment_volume for increasing or decreasing the volume by a fixed amount
script increment_volume
// if the configured hotkey for ignoring the input trigger is pressed
if ($parameters IgnoreKey) && (keystate ($parameters IgnoreKey))
return
// Get the target process from the parameters
$target = (runscript default get_target parameters:$parameters)
// get the volume from the target process and add the increment to it
$volume = (round (getvolume $target) + ($parameters Amount))
// set the volume
runscript default set_volume volume:$volume,target:$target
script set_volume hidden
// change the volume of the target
setvolume $volume $target
// update the mute state of the target, if necessary
if $volume < 3 && !(getmute $target)
setmute true $target
if $volume >= 3 && (getmute $target)
setmute false $target
// indicate the volume level on the logo indicator across a range from green to red.
indicator true (R: $volume * 5.11,G: 5.11 * (100 - $volume), B: 0) 1
script get_target private
// if 'foreground' is specified as target, or the configured hotkey for the foreground is pressed
if ($parameters Target) == foreground || (($parameters ForegroundKey) && (keystate ($parameters ForegroundKey)))
return (getfocusedprocess)
// if the translation parameters specify a target, use that instead
else if ($parameters Target) && ($parameters Target) != "*"
return ($parameters Target)
// define the parameters to be displayed in a translation.
event uirefreshed
// define common controls
$target = (textbox "Target" "The process to change the volume of. A blank value or '*' will target the system volume. 'foreground' will target the foreground application.''" "*")
$foreground = (textbox "Foreground Key" "The key to press down when the script should modify the volume of the foreground app instead of the target." CTRL 0.3)
$ignore = (textbox "Ignore key" "The key to press down for when the script should do nothing while the MIDI input is triggered." SHIFT 0.3)
// default script parameters
if (platform) == Windows
translationparameter Target $target
translationparameter ForegroundKey $foreground
translationparameter IgnoreKey $ignore
// increment_volume script parameters
translationparameter Amount (numberbox "Volume Amount" "The amount to increase or decrease the volume with." 5 default false -100 100 5) increment_volume
if (platform) == Windows
translationparameter Target $target increment_volume
translationparameter ForegroundKey $foreground increment_volume
translationparameter IgnoreKey $ignore increment_volume
99 downloads