3 name = "Stop at Marker",
5 author = "Ardour Lua Task Force",
6 description = [[An example session script which stops the transport on every location marker when rolling forward.]]
10 return function (n_samples)
11 if (not Session:transport_rolling ()) then
12 -- not rolling, nothing to do.
16 local pos = Session:transport_frame () -- current playhead position
17 local loc = Session:locations () -- all marker locations
19 -- find first marker after the current playhead position, ignore loop + punch ranges
20 -- (this only works when rolling forward, to extend this example see
21 -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Locations )
22 local m = loc:first_mark_after (pos, false)
25 -- no marker was found
29 -- since ardour may split the process cycle for events,
30 -- n_samples may be smaller.
31 local blk = Session:get_block_size ()
33 -- transport stop can only happen on a process-cycle boundary.
34 -- This callback happens from within the process callback,
35 -- so we need to queue it ahead of time.
36 if (pos + n_samples + blk >= m and pos + n_samples < m) then
37 Session:request_transport_speed (0.0, true)