Opening an item in the MIDI editor parks the edit cursor at the item
start, and the open action then made that stick. Listening to a phrase
and hitting Alt+Shift+G to write on top of it meant arrowing back to
where you already were, one cell at a time, on every entry.
The cursor now stays where it was and is only tidied onto the nearest
grid line, so the first left/right press moves a whole cell rather than
a remainder. The action reads the cursor before the open command runs,
since the open command is what moves it.
snapCursorToCell rounds in quarter notes, like everything else here, so
the landing spot survives a tempo change, and clamps the cell index into
the item: the floor is the cell containing the item start, which is
where the action used to land, and the ceiling is the last cell that
starts inside the item. Clamping the index rather than the time means a
cursor parked before an off-grid item start rounds forward into the
first whole cell instead of into the partial one, where a note would
begin outside the item.
The action also re-reads the take from the editor handle now, so the
grid size and the spoken position come from the take actually being
edited rather than from the selected item's active take.
Toggling grid mode on with Alt+G is left alone: it does not move the
cursor at all, and cell() floors, so an off-grid cursor still works.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Arrowing cell by cell is right inside a dense bar and tedious across an
empty one. Three pairs of keys now jump straight to a note that is really
there, one pair for each axis:
Alt+Up/Down the column -- next pitch sounding in this cell
Alt+Left/Right the row -- next note at the cursor's pitch
Ctrl+Alt+Left/Right anywhere -- next note in the take, any pitch
plus Ctrl+Alt+Up/Down for whole-octave movement, which needs no scale
awareness because an octave preserves the pitch class.
All the jumps ignore muted notes, which are not audible content, and the
row and any-note jumps anchor on note starts, so a note held across eight
cells is one stop rather than eight. Landing in a chord takes whichever
note is nearest the pitch you came from rather than always the bottom one.
They sit on Ctrl+Alt rather than plain Ctrl because REAPER already uses
Ctrl+arrows to move between items.
The logic lives in the lib as usual, with four run* drivers following the
runShift pattern, so the eight new action scripts are seven lines each.
test_lib.lua previously dofile'd an absolute D:\ path and so could not run
outside one machine; it now resolves the lib relative to itself. Stubbing
MIDI_GetNote and the PPQ conversions reaches further than the old "pure
logic only" boundary, so the new tests cover the search functions and the
drivers' speech and cursor movement too.
StuffMIDIMessage feeds the virtual MIDI keyboard, which only reaches
tracks that are armed and monitoring -- normally not the track whose
item you are editing. Opening an item in grid mode therefore sounded
every preview through whatever instrument happened to be armed, which
is confusing when the notes you are writing come back in the wrong
voice.
Grid mode now borrows the record routing: the edited take's track is
armed and monitoring with all MIDI inputs (anything narrower can
exclude the virtual keyboard), and every other armed track is stood
down so it cannot answer as well. The prior arm, monitor and input of
each track touched is saved by GUID in transient ExtState.
routePreview re-points lazily, so moving the editor to an item on
another track costs nothing until the target actually changes. The
daemon hands the routing back when grid mode goes off, when the editor
closes, or on exit -- the same way it already restores the loop and
repeat state the loop-bar action borrows -- so the project is put back
even if grid mode is never toggled off.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Chords are built by stacking scale thirds rather than from a quality table,
so the chord follows the degree automatically -- in C major, Alt+3 on C gives
C major, on D gives D minor, on B gives B diminished. Toggling delegates to
toggleCell, so chord tones inherit hold-mode joining, splitting and trimming
unchanged.
Velocity keys act on the note under the cursor if there is one, and on the
default for new notes otherwise, announcing which. That avoids a mode switch
between setting a level to draw at and shaping dynamics after the fact.
Also fixes install.ps1 failing to resolve its own directory: $PSScriptRoot is
not reliably populated during parameter binding, so it is resolved in the body.
Tests cover chord quality per scale degree and range clamping.
Keyboard- and speech-driven step entry for the MIDI editor, built for use
with OSARA. Arrows walk grid cells and scale degrees, Enter toggles notes,
and every position is spoken and auditioned.
Uses REAPER's own edit cursor and active_note_row rather than private cursor
state, so grid mode and OSARA editing stay in sync. Grid size comes from
MIDI_GetGrid(), so existing grid keybindings drive it. When grid mode is off,
every bound key forwards to its previous action.
Preview timing lives in a background daemon so the action scripts can exit
immediately -- a script still alive on the next keypress triggers REAPER's
"already running" prompt and breaks key repeat.