# (Reaper script) Legato nudge: CC values move with notes and respect note boundaries



## pmcrockett (Feb 23, 2018)

A couple people expressed interest in this script over in this thread (@Saxer, @alb13), so here it is for anyone who wants to take a look at it.

This is a note nudge/resize script that keeps the appropriate CC data attached to the note and scales that CC data's duration to follow changes in the note's duration. Additionally, the CC data will respect legato overlaps. This means that you can nudge a note into the subsequent note and the two notes' CC data won't overlap but rather will be scaled in a way that respects the overlap boundary. The attack portion of the CC data is scaled more weakly in order to preserve the existing character of dynamics automation as much as possible. Take a look at this gif to see what this all looks like in action:






There are four versions of the script in the zip file -- two nudge sizes in either direction. To install, load the script files from the Reaper Action list (Action > Show action list ...). They can then be run from the Action list or bound to a keyboard command. If you want the script files to live in the same place as all of the default Reaper scripts, you can put them in your Reaper script folder. On my (Windows 10) machine, this folder is C:\Users\yourusername\AppData\Roaming\REAPER\Scripts.

To modify the nudge values, change the initialization values at the top of the script in a text editor or by using the Edit button in the Action list. You can copy and modify one of the script files if you want additional versions. (Technical note: It's possible to put all the function calls in a separate script by using Lua's "require" command to avoid the massive code duplication of just copying the whole script like I've done here, but it involves setting a Windows environment variable for Lua, which I don't really want to walk people through. I also have no idea what the Mac equivalent is.)

This script is pulled from a larger Lemur-based editing suite that I'm working on and should be considered a proof-of-concept/work-in-progress. There are bugs I know about, and probably more that I don't. And some of the code is ugly -- I had only very fuzzy design goals and didn't know anything about Lua or the Reaper API back when I started this project, so the whole thing is a bit of a Frankenstein's monster.

Known issues:
Nudging a note fully beyond the start of a neighbor note will glitch the CC data.

The script is designed strictly for monophonic lines. It doesn't work correctly if used with chords.

The script does some automatic management of item size, and this can sometimes make the view jump around.


----------

