1 ardour { ["type"] = "Snippet", name = "Editor Selection" }
3 function factory () return function ()
4 -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:Selection
5 -- the Ardour Selection can include multiple items
6 -- (regions, tracks, ranges, markers, automation, midi-notes etc)
7 local sel = Editor:get_selection ()
10 -- At the point of writing the following data items are available
13 -- Range selection, total span of all ranges (0, 0 if no time range is selected)
14 if sel.time:start () < sel.time:end_frame () then
15 print ("Total Range:", sel.time:start (), sel.time:end_frame ())
18 -- Range selection, individual ranges.
19 for ar in sel.time:iter () do
20 -- each of the items is a
21 -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:AudioRange
22 print ("Range:", ar.id, ar.start, ar._end)
25 -- Track/Bus Selection
26 -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:TrackSelection
27 for r in sel.tracks:routelist ():iter () do
28 -- each of the items is a
29 -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Route
30 print ("Route:", r:name ())
34 -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:RegionSelection
35 for r in sel.regions:regionlist ():iter () do
36 -- each of the items is a
37 -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Region
38 print ("Region:", r:name ())
42 -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:MarkerSelection
43 -- Note: Marker selection is not cleared and currently (Ardour-4.7) points
44 -- to the most recently selected marker.
45 for m in sel.markers:iter () do
46 -- each of the items is a
47 -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOURUI::ArdourMarker
48 print ("Marker:", m:name (), m:position(), m:_type())
51 ----------------------------------------------------------
52 -- The total time extents of all selected regions and ranges
53 local ok, ext = Editor:get_selection_extents (0, 0)
55 print ("Selection Extents:", ext[1], ext[2])
57 print ("No region or range is selected")