snap_midi_notes_to_scale
Snap off-key MIDI notes to a chosen scale in REAPER, moving each wrong pitch to the nearest in-scale tone to fix notes or force a part into key.
Instructions
Snap off-key MIDI notes onto a scale (fix a wrong note, force a part into a key).
Notes already in the scale are left alone; each off-scale note moves to the nearest
in-scale pitch, and under nearest a tie resolves toward the middle of the selection.
A note with no in-scale pitch left inside 0-127 stays put and is counted in skipped.
Args: root: Root pitch class, 0-11 (0=C, 1=C#, 2=D ... 11=B). mode: Scale name: major, minor, harmonic_minor, melodic_minor, dorian, phrygian, lydian, mixolydian, locrian, major_pentatonic, minor_pentatonic, blues, whole_tone, chromatic (aliases: ionian, aeolian, natural_minor). Or a custom list of semitone intervals from the root, each 0-11 (e.g. [0,2,4,7,9]). direction: "nearest" (closest scale tone), "up" or "down" (that way only, skipping a note rather than falling back to the other direction).
Returns:
{ok, notes_changed, clamped, skipped, out_of_bounds, notes:[...]}; notes is the
post-transform list, with indices re-synced after the sort.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | major | |
| root | Yes | ||
| fields | No | ||
| channel | No | ||
| end_beat | No | ||
| direction | No | nearest | |
| pitch_low | No | ||
| item_index | Yes | ||
| pitch_high | No | ||
| start_beat | No | ||
| track_index | Yes | ||
| return_notes | No |