summaryrefslogtreecommitdiff
path: root/scripts/s_fader_automation.lua
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-04-11 14:36:57 +0200
committerRobin Gareus <robin@gareus.org>2016-04-11 14:36:57 +0200
commitbaf631961360b1158f25b743f0bedfa60bc428f4 (patch)
treecc5a714595ab06282d62656465b54567e02e02f2 /scripts/s_fader_automation.lua
parentd21f20290515817cd7664301912184edb43c1845 (diff)
update and cleanup lua example scripts
Diffstat (limited to 'scripts/s_fader_automation.lua')
-rw-r--r--scripts/s_fader_automation.lua39
1 files changed, 23 insertions, 16 deletions
diff --git a/scripts/s_fader_automation.lua b/scripts/s_fader_automation.lua
index e1ee2876e4..aaac7adfe9 100644
--- a/scripts/s_fader_automation.lua
+++ b/scripts/s_fader_automation.lua
@@ -1,46 +1,53 @@
-ardour { ["type"] = "Snippet", name = "fader automation" }
+ardour { ["type"] = "Snippet", name = "Fader Automation" }
function factory () return function ()
local playhead = Session:transport_frame ()
local samplerate = Session:nominal_frame_rate ()
-- get selected tracks
- rl = Editor:get_selection().tracks:routelist()
+ rl = Editor:get_selection ().tracks:routelist ()
+
-- prepare undo operation
Session:begin_reversible_command ("Fancy Fade Out")
local add_undo = false -- keep track if something has changed
- -- iterate over selected tracks
- for r in rl:iter() do
- local ac = r:amp():gain_control() -- ARDOUR:AutomationControl
- local acl = ac:alist() -- ARDOUR:AutomationControlList (state, high-level)
- local cl = acl:list() -- Evoral:ControlList (actual events)
- ac:set_automation_state(ARDOUR.AutoState.Touch)
+ -- 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)
+ local cl = al:list () -- Evoral:ControlList (actual events)
- if cl:isnil() then
+ if cl:isnil () then
goto out
end
+ -- set automation state to "Touch"
+ ac:set_automation_state (ARDOUR.AutoState.Touch)
+
-- query the value at the playhead position
- local g = cl:eval(playhead)
+ local g = cl:eval (playhead)
-- get state for undo
- local before = acl:get_state()
+ local before = al:get_state ()
-- delete all events after the playhead...
cl:truncate_end (playhead)
+
-- ...and generate some new ones.
for i=0,50 do
+ -- use a sqrt fade-out (the shape is recognizable, and otherwise
+ -- not be possible to achieve with existing ardour fade shapes)
cl:add (playhead + i * samplerate / 50,
- g * (1 - math.sqrt (i / 50)),
- false, true)
+ g * (1 - math.sqrt (i / 50)),
+ false, true)
end
+
-- remove dense events
- cl:thin(20)
+ cl:thin (20)
-- save undo
- local after = acl:get_state()
- Session:add_command (acl:memento_command(before, after))
+ local after = al:get_state ()
+ Session:add_command (al:memento_command (before, after))
add_undo = true
::out::