Add play-current-bar-only

Ctrl+Alt+Space plays the cursor's bar and stops at the next bar line, so the
same bar can be fired repeatedly while nudging a note without reaching for
stop. Alt+Space keeps its play-onwards behaviour.

The stop is performed by the preview daemon rather than the action script: a
script that stayed alive waiting for the bar to end would bring back REAPER's
"already running" prompt on the next press, which is the problem the daemon
exists to avoid. Stopping transport can move the edit cursor depending on
preferences, and the edit cursor is the grid cursor, so the daemon restores it.

A short arming window covers the gap between requesting playback and the
transport reporting as playing, so the pending stop is not cancelled instantly.
This commit is contained in:
2026-08-14 20:04:20 +02:00
parent 8fd1b4755f
commit fc378e733b
6 changed files with 71 additions and 14 deletions
+18
View File
@@ -49,6 +49,24 @@ local function loop()
allOff()
end
-- Pending "stop at end of bar" request, posted by the play-one-bar action.
local stopAt = tonumber(G.getTemp("stopat", ""))
if stopAt then
local playing = (reaper.GetPlayState() % 2) == 1
if playing and reaper.GetPlayPosition() >= stopAt then
-- Stopping can move the edit cursor depending on preferences, and the
-- edit cursor is the grid cursor, so put it back.
local cur = reaper.GetCursorPosition()
reaper.CSurf_OnStop()
reaper.SetEditCurPos(cur, false, false)
G.setTemp("stopat", "")
elseif not playing
and reaper.time_precise() > (tonumber(G.getTemp("stoparm", "0")) or 0) then
-- Transport stopped by other means; drop the pending request.
G.setTemp("stopat", "")
end
end
reaper.defer(loop)
end