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_sample () -- 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
30 -- transport stop can only happen on a process-cycle boundary.
31 -- This callback happens from within the process callback,
32 -- so we need to queue it ahead of time.
33 local blk = Session:get_block_size ()
34 if (pos + blk<= m and pos + blk + n_samples > m ) then
35 -- TODO use session event API, schedule stop at marker's time
36 Session:request_transport_speed (0.0, true, ARDOUR.TransportRequestSource.TRS_Engine)