2016-04-11 08:36:57 -04:00
|
|
|
ardour { ["type"] = "Snippet", name = "Fader Automation" }
|
2016-04-10 14:57:24 -04:00
|
|
|
|
|
|
|
function factory () return function ()
|
2017-09-26 23:03:10 -04:00
|
|
|
local playhead = Session:transport_sample ()
|
|
|
|
local samplerate = Session:nominal_sample_rate ()
|
2016-04-10 14:57:24 -04:00
|
|
|
|
|
|
|
-- get selected tracks
|
2016-04-11 08:36:57 -04:00
|
|
|
rl = Editor:get_selection ().tracks:routelist ()
|
|
|
|
|
2016-04-10 14:57:24 -04:00
|
|
|
-- prepare undo operation
|
|
|
|
Session:begin_reversible_command ("Fancy Fade Out")
|
|
|
|
local add_undo = false -- keep track if something has changed
|
|
|
|
|
2016-04-11 08:36:57 -04:00
|
|
|
-- iterate over selected tracks
|
|
|
|
for r in rl:iter () do
|
|
|
|
local ac = r:amp ():gain_control () -- ARDOUR:AutomationControl
|
|
|
|
local al = ac:alist () -- ARDOUR:AutomationList (state, high-level)
|
2016-04-10 14:57:24 -04:00
|
|
|
|
2016-04-11 08:36:57 -04:00
|
|
|
-- set automation state to "Touch"
|
|
|
|
ac:set_automation_state (ARDOUR.AutoState.Touch)
|
|
|
|
|
2016-04-10 14:57:24 -04:00
|
|
|
-- query the value at the playhead position
|
2017-04-23 22:12:13 -04:00
|
|
|
local g = al:eval (playhead)
|
2016-04-10 14:57:24 -04:00
|
|
|
|
|
|
|
-- get state for undo
|
2016-04-11 08:36:57 -04:00
|
|
|
local before = al:get_state ()
|
2016-04-10 14:57:24 -04:00
|
|
|
|
|
|
|
-- delete all events after the playhead...
|
2017-04-23 22:12:13 -04:00
|
|
|
al:truncate_end (playhead)
|
2016-04-11 08:36:57 -04:00
|
|
|
|
2016-04-10 14:57:24 -04:00
|
|
|
-- ...and generate some new ones.
|
|
|
|
for i=0,50 do
|
2016-04-11 08:36:57 -04:00
|
|
|
-- use a sqrt fade-out (the shape is recognizable, and otherwise
|
|
|
|
-- not be possible to achieve with existing ardour fade shapes)
|
2017-04-23 22:12:13 -04:00
|
|
|
al:add (playhead + i * samplerate / 50,
|
2016-04-11 08:36:57 -04:00
|
|
|
g * (1 - math.sqrt (i / 50)),
|
|
|
|
false, true)
|
2016-04-10 14:57:24 -04:00
|
|
|
end
|
2016-04-11 08:36:57 -04:00
|
|
|
|
2016-04-10 14:57:24 -04:00
|
|
|
-- remove dense events
|
2017-04-23 22:12:13 -04:00
|
|
|
al:thin (20)
|
2016-04-10 14:57:24 -04:00
|
|
|
|
|
|
|
-- save undo
|
2016-04-11 08:36:57 -04:00
|
|
|
local after = al:get_state ()
|
|
|
|
Session:add_command (al:memento_command (before, after))
|
2016-04-10 14:57:24 -04:00
|
|
|
add_undo = true
|
|
|
|
|
|
|
|
::out::
|
|
|
|
end
|
|
|
|
|
|
|
|
-- all done, commit the combined Undo Operation
|
|
|
|
if add_undo then
|
Fix various typos
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sord,sur,te,trough,ue`
Follow-up to 364f2f078
2022-04-07 09:09:04 -04:00
|
|
|
-- the 'nil' Command here means to use the collected diffs added above
|
2016-04-10 14:57:24 -04:00
|
|
|
Session:commit_reversible_command (nil)
|
|
|
|
else
|
|
|
|
Session:abort_reversible_command ()
|
|
|
|
end
|
|
|
|
end end
|