mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 20:26:30 +01:00
Add tom's additions to tom's loop and turn it into an Action Script
This commit is contained in:
parent
121cd66fd6
commit
f67c204121
1 changed files with 53 additions and 11 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
ardour { ["type"] = "Snippet", name = "Tom's Loop",
|
ardour { ["type"] = "EditorAction", name = "Tom's Loop",
|
||||||
license = "MIT",
|
license = "MIT",
|
||||||
author = "Robin Gareus",
|
author = "Robin Gareus",
|
||||||
email = "robin@gareus.org",
|
email = "robin@gareus.org",
|
||||||
|
|
@ -6,16 +6,15 @@ ardour { ["type"] = "Snippet", name = "Tom's Loop",
|
||||||
description = [[Bounce the loop-range of all non muted audio tracks, paste N times at playhead]]
|
description = [[Bounce the loop-range of all non muted audio tracks, paste N times at playhead]]
|
||||||
}
|
}
|
||||||
|
|
||||||
-- unused ; cfg parameter for ["type"] = "EditorAction"
|
|
||||||
function action_params ()
|
function action_params ()
|
||||||
return { ["times"] = { title = "Number of copies to add", default = "1"}, }
|
return { ["times"] = { title = "Number of copies to add", default = "1"}, }
|
||||||
end
|
end
|
||||||
|
|
||||||
function factory () return function ()
|
function factory (params) return function ()
|
||||||
-- get options
|
-- get options
|
||||||
local p = params or {}
|
local p = params or {}
|
||||||
local npaste = p["times"] or 1
|
local n_paste = tonumber (p["times"] or 1)
|
||||||
assert (npaste > 0)
|
assert (n_paste > 0)
|
||||||
|
|
||||||
local proc = ARDOUR.LuaAPI.nil_proc () -- bounce w/o processing
|
local proc = ARDOUR.LuaAPI.nil_proc () -- bounce w/o processing
|
||||||
local itt = ARDOUR.InterThreadInfo () -- bounce progress info (unused)
|
local itt = ARDOUR.InterThreadInfo () -- bounce progress info (unused)
|
||||||
|
|
@ -38,33 +37,67 @@ function factory () return function ()
|
||||||
Session:begin_reversible_command ("Tom's Loop")
|
Session:begin_reversible_command ("Tom's Loop")
|
||||||
local add_undo = false -- keep track if something has changed
|
local add_undo = false -- keep track if something has changed
|
||||||
|
|
||||||
|
-- prefer solo'ed tracks
|
||||||
|
local soloed_track_found = false
|
||||||
for route in Session:get_tracks ():iter () do
|
for route in Session:get_tracks ():iter () do
|
||||||
-- skip muted tracks
|
if route:soloed () then
|
||||||
|
soloed_track_found = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- count regions that are bounced
|
||||||
|
local n_regions_created = 0
|
||||||
|
|
||||||
|
-- loop over all tracks in the session
|
||||||
|
for route in Session:get_tracks ():iter () do
|
||||||
|
if soloed_track_found then
|
||||||
|
-- skip not soloed tracks
|
||||||
|
if not route:soloed () then
|
||||||
|
goto continue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- skip muted tracks (also applies to soloed + muted)
|
||||||
if route:muted () then
|
if route:muted () then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- at this point the track is either soloed (if at least one track is soloed)
|
||||||
|
-- or not muted (if no track is soloed)
|
||||||
|
|
||||||
-- test if bouncing is possible
|
-- test if bouncing is possible
|
||||||
local track = route:to_track ()
|
local track = route:to_track ()
|
||||||
if not track:bounceable (proc, false) then
|
if not track:bounceable (proc, false) then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
-- only audio tracks
|
-- only audio tracks
|
||||||
local playlist = track:playlist ()
|
local playlist = track:playlist ()
|
||||||
if playlist:data_type ():to_string () ~= "audio" then
|
if playlist:data_type ():to_string () ~= "audio" then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check if there are any regions in the loop-range of this track
|
-- check if there is at least one unmuted region in the loop-range
|
||||||
if playlist:regions_touched (loop:start (), loop:_end ()):empty () then
|
local reg_unmuted_count = 0
|
||||||
|
for reg in playlist:regions_touched (loop:start (), loop:_end ()):iter () do
|
||||||
|
if not reg:muted() then
|
||||||
|
reg_unmuted_count = reg_unmuted_count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if reg_unmuted_count < 1 then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
-- clear existing changes, prepare "diff" of state
|
-- clear existing changes, prepare "diff" of state for undo
|
||||||
playlist:to_stateful ():clear_changes ()
|
playlist:to_stateful ():clear_changes ()
|
||||||
|
|
||||||
-- do the actual work
|
-- do the actual work
|
||||||
local region = track:bounce_range (loop:start (), loop:_end (), itt, proc, false)
|
local region = track:bounce_range (loop:start (), loop:_end (), itt, proc, false)
|
||||||
playlist:add_region (region, playhead, npaste, false)
|
playlist:add_region (region, playhead, n_paste, false)
|
||||||
|
|
||||||
|
n_regions_created = n_regions_created + 1
|
||||||
|
|
||||||
-- create a diff of the performed work, add it to the session's undo stack
|
-- create a diff of the performed work, add it to the session's undo stack
|
||||||
-- and check if it is not empty
|
-- and check if it is not empty
|
||||||
|
|
@ -74,12 +107,21 @@ function factory () return function ()
|
||||||
|
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--advance playhead so it's just after the newly added regions
|
||||||
|
if n_regions_created > 0 then
|
||||||
|
Session:request_locate((playhead + loop:length() * n_paste),false)
|
||||||
|
end
|
||||||
|
|
||||||
-- all done, commit the combined Undo Operation
|
-- all done, commit the combined Undo Operation
|
||||||
if add_undo then
|
if add_undo then
|
||||||
-- the 'nil' Commend here mean to use the collected diffs added above
|
-- the 'nil' Command here mean to use the collected diffs added above
|
||||||
Session:commit_reversible_command (nil)
|
Session:commit_reversible_command (nil)
|
||||||
else
|
else
|
||||||
Session:abort_reversible_command ()
|
Session:abort_reversible_command ()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print ("bounced " .. n_regions_created .. " regions from loop range (" .. loop:length() .. " frames) to playhead @ frame # " .. playhead)
|
||||||
|
|
||||||
::errorout::
|
::errorout::
|
||||||
end end
|
end end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue