Release notch-bank filter
[ardour.git] / scripts / s_thin_automation.lua
1 ardour { ["type"] = "Snippet", name = "Thin Fader Automation" }
2
3 -- --TODO--
4 -- For a fully fledged EditorAction this script should
5 -- offer a dropdown to select automation of all paramaters
6 -- (not just the fader)
7 -- see scripts/midi_cc_to_automation.lua and
8 -- scripts/mixer_settings_store.lua
9 -- Thinning Area should also be a numeric-entry or slider
10
11 function factory () return function ()
12         -- get selected tracks
13         rl = Editor:get_selection ().tracks:routelist ()
14
15         -- prepare undo operation
16         Session:begin_reversible_command ("Thin Automation")
17         local add_undo = false -- keep track if something has changed
18
19         -- iterate over selected tracks
20         for r in rl:iter () do
21
22                 -- get the Fader (aka "amp") control
23                 local ac = r:amp ():gain_control () -- ARDOUR:AutomationControl
24                 local al = ac:alist () -- ARDOUR:AutomationList
25
26                 -- get state for undo
27                 local before = al:get_state ()
28
29                 -- remove dense events
30                 al:thin (50) -- threashold of area below curve
31
32                 -- save undo
33                 local after = al:get_state ()
34                 Session:add_command (al:memento_command (before, after))
35                 add_undo = true
36
37                 ::out::
38         end
39
40         -- all done, commit the combined Undo Operation
41         if add_undo then
42                 -- the 'nil' Commend here mean to use the collected diffs added above
43                 Session:commit_reversible_command (nil)
44         else
45                 Session:abort_reversible_command ()
46         end
47 end end