Last active
December 24, 2021 15:28
-
-
Save mwicat/560238cfef1bb1a4715206f7e6903e97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on init | |
set_script_title("Shift Sample") | |
declare ui_knob $Pitch (-24, 24, 1) | |
declare ui_knob $Velocity (-127, 127, 1) | |
declare $VelocityTarget | |
declare $VolumeAdd | |
declare $NoteTarget | |
declare $PitchAdd | |
$Pitch := 0 | |
$Velocity := 0 | |
set_knob_defval ($Pitch,0) | |
make_persistent ($Pitch) | |
set_knob_unit ($Pitch,$KNOB_UNIT_ST) | |
set_control_help ($Pitch,"Pitch: Shifts the pitch in semitones while simultaneously compensating with | |
midi transpose in the opposite direction.") | |
set_knob_defval ($Velocity,0) | |
make_persistent ($Velocity) | |
set_control_help ($Velocity,"Velocity: Shifts the velocity while simultaneously compensating with | |
volume shift in the opposite direction.") | |
end on | |
on note | |
$VelocityTarget := $EVENT_VELOCITY + $Velocity | |
if ($VelocityTarget < 0) | |
$VelocityTarget := 0 | |
end if | |
if ($VelocityTarget > 127) | |
$VelocityTarget := 127 | |
end if | |
$VolumeAdd := ($EVENT_VELOCITY - $VelocityTarget) * 300 | |
$NoteTarget := $EVENT_NOTE-$Pitch | |
if ($NoteTarget < 0) | |
$NoteTarget := 0 | |
end if | |
if ($NoteTarget > 127) | |
$NoteTarget := 127 | |
end if | |
$PitchAdd := $Pitch * 100000 | |
if ($VelocityTarget # $EVENT_VELOCITY) | |
change_velo($EVENT_ID, $VelocityTarget) | |
change_vol($EVENT_ID,$VolumeAdd,1) | |
end if | |
if ($NoteTarget # $EVENT_NOTE) | |
change_note($EVENT_ID,$NoteTarget) | |
change_tune($EVENT_ID,$PitchAdd,1) | |
end if | |
end on | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment