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 if fader_value == 1 then
25 if t:gain_control():automation_state() ~= ARDOUR.AutoState.Off then
29 -- TODO: skip MIDI tracks without or with a post-fader synth
30 -- (fader is MIDI-velocity)
32 v = math.log(fader_value, 10)
39 -- find the fader proc
40 proc = t:nth_processor (i)
41 if (not proc:isnil() and proc:display_name () == "Fader") then
48 trim = t:nth_processor (fader_pos+1)
49 if (not trim:isnil() and trim:display_name () == "a-Amplifier") then
50 --existing trim found; sum the trim and the fader gain, and set the trim to that value
51 cur_gain = ARDOUR.LuaAPI.get_processor_param (trim, 0)
52 ARDOUR.LuaAPI.set_processor_param (trim, 0, trim_gain+cur_gain)
54 --create a new Trim processor, and set its value to match the fader
55 local a = ARDOUR.LuaAPI.new_luaproc(Session, "a-Amplifier");
56 if (not a:isnil()) then
57 t:add_processor_by_index(a, fader_pos-1, nil, true)
58 ARDOUR.LuaAPI.set_processor_param (a, 0, trim_gain)
59 a = nil -- explicitly drop shared-ptr reference
64 t:gain_control():set_value(1, PBD.GroupControlDisposition.NoGroup)