2 ["type"] = "EditorAction",
3 name = "Faders to Trims",
6 description = [[Add 'Trim' plugins to all tracks. Move the fader value into the trim.]]
9 function action_params ()
16 function factory (params)
18 -- loop over all tracks
19 for t in Session:get_tracks():iter() do
21 fader_value = t:gain_control():get_value()
22 v = math.log(fader_value, 10)
29 -- find the fader proc
30 proc = t:nth_processor (i)
31 if (not proc:isnil() and proc:display_name () == "Fader") then
38 trim = t:nth_processor (fader_pos+1)
39 if (not trim:isnil() and trim:display_name () == "a-Amplifier") then
40 --existing trim found; sum the trim and the fader gain, and set the trim to that value
41 cur_gain = ARDOUR.LuaAPI.get_processor_param (trim, 0)
42 ARDOUR.LuaAPI.set_processor_param (trim, 0, trim_gain+cur_gain)
44 --create a new Trim processor, and set its value to match the fader
45 local a = ARDOUR.LuaAPI.new_luaproc(Session, "a-Amplifier");
46 if (not a:isnil()) then
47 t:add_processor_by_index(a, fader_pos-1, nil, true)
48 ARDOUR.LuaAPI.set_processor_param (a, 0, trim_gain)
49 a = nil -- explicitly drop shared-ptr reference
54 t:gain_control():set_value(1, PBD.GroupControlDisposition.NoGroup)