Skip to content

Instantly share code, notes, and snippets.

@shcipwa
Created November 25, 2022 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shcipwa/1050ac04e295dee1a6c2767eeef8a766 to your computer and use it in GitHub Desktop.
Save shcipwa/1050ac04e295dee1a6c2767eeef8a766 to your computer and use it in GitHub Desktop.
A Kontact script (KSP) that turns pitch bend into a toggleable sustain pedal
on init
make_perfview
declare ui_switch $Sustain
make_persistent($Sustain)
declare $lastsusbyte := 63
declare $enabled := 1
declare $prevsus := 0
end on
on ui_control ($Sustain)
if($enabled > 0 and $Sustain > 0)
set_midi(0,$MIDI_COMMAND_CC,64,127)
else
set_midi(0,$MIDI_COMMAND_CC,64,0)
end if
end on
on midi_in
if($Sustain > 0)
if($MIDI_COMMAND = 224)
ignore_midi
message($MIDI_BYTE_2)
$prevsus := $lastsusbyte
$lastsusbyte := $MIDI_BYTE_2
if($lastsusbyte < 63)
if($prevsus = 63)
$enabled := $enabled * -1
if($enabled > 0)
set_midi(0,$MIDI_COMMAND_CC,64,127)
else
set_midi(0,$MIDI_COMMAND_CC,64,0)
end if
end if
else
if($lastsusbyte = 63)
set_midi(0,$MIDI_COMMAND_CC,64,$enabled * 127)
else
set_midi(0,$MIDI_COMMAND_CC,64,$enabled * 127 * -1)
end if
end if
end if
end if
end on
@shcipwa
Copy link
Author

shcipwa commented Nov 25, 2022

I originally wrote this for playing Piano using Native Instruments Maschine without a sustain pedal, but should work with any keyboard with a pitch bend wheel

When enabled, it will intercept pitch bend midi messages as controls for a virtual sustain pedal.
How it works:
Pitch Bend Down - Toggle sustain state on or off permanently
Pitch Bend Up - Temporary inverse of current state

Example use:
Pitch bend down once to toggle always on, then tap pitch bend up whenever you want to mute currently sustained keys (quick lift of pedal)

Installation:
Click the KSP button on the right of the Multi Rack row at the top of Kontakt,
Click edit on one of the empty scripts
Paste in the script
Click Apply
Close Edit by clicking the Edit button again

To Enable: Click the Sustain button at the top of the page then use pitch bend wheel as described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment