1 ardour { ["type"] = "Snippet", name = "Tom's Loop",
3 author = "Robin Gareus",
4 email = "robin@gareus.org",
5 site = "http://gareus.org",
6 description = [[Bounce the loop-range of all non muted audio tracks, paste N times at playhead]]
9 -- unused ; cfg parameter for ["type"] = "EditorAction"
10 function action_params ()
11 return { ["times"] = { title = "Number of copies to add", default = "1"}, }
14 function factory () return function ()
16 local p = params or {}
17 local npaste = p["times"] or 1
20 local proc = ARDOUR.LuaAPI.nil_proc () -- bounce w/o processing
21 local itt = ARDOUR.InterThreadInfo () -- bounce progress info (unused)
23 local loop = Session:locations ():auto_loop_location ()
24 local playhead = Session:transport_frame ()
26 -- make sure we have a loop, and the playhead (edit point) is after it
27 -- TODO: only print an error and return
28 -- TODO: use the edit-point (not playhead) ? maybe.
30 assert (loop:start () < loop:_end ())
31 assert (loop:_end () < playhead)
33 for route in Session:get_tracks ():iter () do
35 if route:muted () then
38 -- test if bouncing is possible
39 local track = route:to_track ()
40 if not track:bounceable (proc, false) then
44 local playlist = track:playlist ()
45 if playlist:data_type ():to_string() ~= "audio" then
49 -- check if there are any regions in the loop-range of this track
50 local range = Evoral.Range (loop:start (), loop:_end ())
51 if playlist:regions_with_start_within (range):empty () then
54 if playlist:regions_with_end_within (range):empty () then
59 --print (track:name ())
62 local region = track:bounce_range (loop:start (), loop:_end (), itt, proc, false)
63 playlist:add_region(region, playhead, npaste, false)