Stop bar playback before the bar line, not on it
Playing a single bar still triggered notes placed exactly on the next bar line. Two delays stack: the daemon polls at roughly frame rate, so it can notice up to ~33ms late, and REAPER renders audio ahead of the play position it reports, so the note has already reached the instrument before the stop lands. Stopping 60ms early clears both. The cost is a few milliseconds off the tail of the bar, which is inaudible, and the benefit is that the downbeat you were trying to exclude stays excluded. Tunable via the stoplead ExtState for setups with large audio buffers.
This commit is contained in:
+8
-1
@@ -53,7 +53,14 @@ local function loop()
|
||||
local stopAt = tonumber(G.getTemp("stopat", ""))
|
||||
if stopAt then
|
||||
local playing = (reaper.GetPlayState() % 2) == 1
|
||||
if playing and reaper.GetPlayPosition() >= stopAt then
|
||||
-- Stop a little BEFORE the bar line, not on it. Two delays stack up
|
||||
-- otherwise: this loop only runs at about frame rate, and REAPER renders
|
||||
-- audio ahead of the play position it reports -- so a note sitting exactly
|
||||
-- on the next bar line has already been sent to the instrument by the time
|
||||
-- we notice. Leading by more than both delays keeps that note silent.
|
||||
-- Costs a few ms off the tail of the bar, which is inaudible.
|
||||
local lead = G.getNum("stoplead", 0.06)
|
||||
if playing and reaper.GetPlayPosition() >= stopAt - lead 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()
|
||||
|
||||
Reference in New Issue
Block a user