summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-01-31 02:11:04 +0100
committerRobin Gareus <robin@gareus.org>2020-01-31 02:11:41 +0100
commitcb09a0884b594d6d58d2e8ff32ab714ccb0898ed (patch)
tree020e7585c57badd85a0a8ccb368e690aaa59ddc2
parente03136646d3301e2cbd6d9c8a05f28c0ebbdacb3 (diff)
Clarify stop-at-marker transport position logic
-rw-r--r--scripts/stop_at_marker.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/scripts/stop_at_marker.lua b/scripts/stop_at_marker.lua
index 651d2d2a3c..35de3510c4 100644
--- a/scripts/stop_at_marker.lua
+++ b/scripts/stop_at_marker.lua
@@ -27,10 +27,22 @@ function factory ()
return
end
- -- due to "first_mark_after" m is always > pos:
+ -- due to `first_mark_after(pos)` "m" is always > "pos":
-- assert(pos < m)
- -- so in the cycle that crosses "m" we need to stop at 'm'
+ --
+ -- This callback happens from within the process callback:
+ --
+ -- this cycle's end = next cycle start = pos + n_samples.
+ --
+ -- Note that if "m" is exactly at cycle's end, that marker
+ -- will be at "pos" in the next cycle. Since we ask for
+ -- "first_mark_after pos", the marker would not be found.
+ --
+ -- So even though "pos + n_samples" is barely reached,
+ -- we need to stop at "m" in the cycle that crosses or ends at "m".
if (pos + n_samples >= m) then
+ -- asking to locate to "m" ensures that playback continues at "m"
+ -- and the same marker will not be taken into account.
Session:request_locate (m, ARDOUR.LocateTransportDisposition.MustStop, ARDOUR.TransportRequestSource.TRS_Engine)
end
end