Author: Sander
Script Version: 2
Minimum CoyoteMIDI Build: 558
$value = ($trigger pitchbend)
$device = ($trigger device)
// Figure out if the current action is up, down, or nothing, depending on the pitchbend value, if it's near 0 it's down, if it's near its max it's up.
if $value < 3000
$action = -1
else if $value > 15000
$action = 1
else
$action = 0
// If the previous action is the same as the current one, we do nothing to prevent spam firing.
if (%pitchbend_transpose_last_action $device) == $action
return
// Update the acion map
%pitchbend_transpose_last_action $device = $action
// If the offsets map doesn't contain the device yet, add a new entry for this device with the default value of 0.
if %pitchbend_transpose_offsets !contains $device
%pitchbend_transpose_offsets + $device: 0
// increase or decrease the offset for this device accordingly.
%pitchbend_transpose_offsets $device = ((%pitchbend_transpose_offsets $device) + $action * 12)
// Allow for the transpose to be reset
script reset
// If global reset is enabled in the translation, reset the entire offset map.
if ($parameters globalreset)
%pitchbend_transpose_offsets new map
// if global reset is not enabled, only reset the offset for the device that triggered the translation, if it exists.
else if $trigger contains device
%pitchbend_transpose_offsets ($trigger device) = 0
// make sure maps exist
event scriptsloaded
if %pitchbend_transpose_last_action == ""
%pitchbend_transpose_last_action new map
if %pitchbend_transpose_offsets == ""
%pitchbend_transpose_offsets new map
event midi note
// if the note doesn't need to be transposed, do nothing.
if ($trigger silenced) || %pitchbend_transpose_offsets !contains ($trigger device) || (%pitchbend_transpose_offsets ($trigger device)) == 0
return
// get the note and add the transpose offset for this device to it.
$note = (max 0 (min 127 ($trigger note) + (%pitchbend_transpose_offsets ($trigger device))))
// send the transposed note instead and silence the event note.
midi note $note ($trigger velocity) true
indicator true R:255,G:125,B:125 0.5 100
return true
// Provide the translation UI parameters
event uirefreshed
translationparameter globalreset (checkbox "Reset All Devices" "Whether the transpose should be reset on all devices instead of only the device that triggered this translation." false) reset
11 downloads