Add Lua bindings to modify region gain curve
This commit is contained in:
parent
56d6a9b9f4
commit
9448973163
@ -1327,8 +1327,11 @@ LuaBindings::common (lua_State* L)
|
||||
.addFunction ("scale_amplitude", &AudioRegion::scale_amplitude)
|
||||
.addFunction ("maximum_amplitude", &AudioRegion::maximum_amplitude)
|
||||
.addFunction ("rms", &AudioRegion::rms)
|
||||
.addFunction ("envelope", &AudioRegion::envelope)
|
||||
.addFunction ("envelope_active", &AudioRegion::envelope_active)
|
||||
.addFunction ("fade_in_active", &AudioRegion::fade_in_active)
|
||||
.addFunction ("fade_out_active", &AudioRegion::fade_out_active)
|
||||
.addFunction ("set_envelope_active", &AudioRegion::set_envelope_active)
|
||||
.addFunction ("set_fade_in_active", &AudioRegion::set_fade_in_active)
|
||||
.addFunction ("set_fade_in_shape", &AudioRegion::set_fade_in_shape)
|
||||
.addFunction ("set_fade_in_length", &AudioRegion::set_fade_in_length)
|
||||
|
52
share/scripts/s_region_gain_curve.lua
Normal file
52
share/scripts/s_region_gain_curve.lua
Normal file
@ -0,0 +1,52 @@
|
||||
ardour { ["type"] = "Snippet", name = "Set Region Gain Curve" }
|
||||
|
||||
function factory () return function ()
|
||||
-- get Editor GUI Selection
|
||||
-- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:Selection
|
||||
local sel = Editor:get_selection ()
|
||||
|
||||
-- prepare undo operation
|
||||
Session:begin_reversible_command ("Lua Region Gain Curve")
|
||||
|
||||
-- iterate over selected regions
|
||||
-- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:RegionSelection
|
||||
for r in sel.regions:regionlist ():iter () do
|
||||
|
||||
-- test if it's an audio region
|
||||
local ar = r:to_audioregion ();
|
||||
if ar:isnil () then
|
||||
goto next
|
||||
end
|
||||
|
||||
-- get region-gain-curve is-a
|
||||
-- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:AutomationList
|
||||
local al = ar:envelope ()
|
||||
|
||||
-- get state for undo
|
||||
local before = al:get_state ()
|
||||
|
||||
-- delete all current events
|
||||
al:clear_list ()
|
||||
|
||||
-- add some new ones
|
||||
for i=0,50 do
|
||||
al:add (i * r:length () / 50,
|
||||
1 - math.sqrt (i / 50),
|
||||
false, true)
|
||||
end
|
||||
|
||||
-- remove dense events
|
||||
al:thin (20)
|
||||
|
||||
-- save undo
|
||||
local after = al:get_state ()
|
||||
Session:add_command (al:memento_command (before, after))
|
||||
|
||||
::next::
|
||||
end
|
||||
|
||||
if not Session:abort_empty_reversible_command () then
|
||||
Session:commit_reversible_command (nil)
|
||||
end
|
||||
|
||||
end end
|
Loading…
Reference in New Issue
Block a user