summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-02-26 18:04:06 +0100
committerRobin Gareus <robin@gareus.org>2019-02-26 18:05:10 +0100
commit2d33638f29c8ed706bf8c60d535c412f3c7285bc (patch)
tree94a7df4b99ca29a81530a6edffc4c9ff50131311 /scripts
parent19540e5ad7306aaf0a55dae2340de0ef3c353df1 (diff)
Add example script to thin automation
Diffstat (limited to 'scripts')
-rw-r--r--scripts/s_thin_automation.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/scripts/s_thin_automation.lua b/scripts/s_thin_automation.lua
new file mode 100644
index 0000000000..a86b6c71d0
--- /dev/null
+++ b/scripts/s_thin_automation.lua
@@ -0,0 +1,47 @@
+ardour { ["type"] = "Snippet", name = "Thin Fader Automation" }
+
+-- --TODO--
+-- For a fully fledged EditorAction this script should
+-- offer a dropdown to select automation of all paramaters
+-- (not just the fader)
+-- see scripts/midi_cc_to_automation.lua and
+-- scripts/mixer_settings_store.lua
+-- Thinning Area should also be a numeric-entry or slider
+
+function factory () return function ()
+ -- get selected tracks
+ rl = Editor:get_selection ().tracks:routelist ()
+
+ -- prepare undo operation
+ Session:begin_reversible_command ("Thin Automation")
+ local add_undo = false -- keep track if something has changed
+
+ -- iterate over selected tracks
+ for r in rl:iter () do
+
+ -- get the Fader (aka "amp") control
+ local ac = r:amp ():gain_control () -- ARDOUR:AutomationControl
+ local al = ac:alist () -- ARDOUR:AutomationList
+
+ -- get state for undo
+ local before = al:get_state ()
+
+ -- remove dense events
+ al:thin (50) -- threashold of area below curve
+
+ -- save undo
+ local after = al:get_state ()
+ Session:add_command (al:memento_command (before, after))
+ add_undo = true
+
+ ::out::
+ end
+
+ -- all done, commit the combined Undo Operation
+ if add_undo then
+ -- the 'nil' Commend here mean to use the collected diffs added above
+ Session:commit_reversible_command (nil)
+ else
+ Session:abort_reversible_command ()
+ end
+end end