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