1ardour { ["type"] = "Snippet", name = "Ducks" } 2 3function factory (params) return function () 4 5 local chan_out = 2 6 if not Session:master_out():isnil() then 7 chan_out = Session:master_out():n_inputs ():n_audio () 8 end 9 10 -- create two mono tracks 11 local tl = Session:new_audio_track (1, chan_out, nil, 2, "Ducks", ARDOUR.PresentationInfo.max_order, ARDOUR.TrackMode.Normal, true) 12 for t in tl:iter() do 13 t:set_strict_io (true) 14 -- switch tracks to monitor input 15 t:monitoring_control():set_value (ARDOUR.MonitorChoice.MonitorInput, PBD.GroupControlDisposition.NoGroup) 16 end 17 18 local src = tl:front (); 19 local dst = tl:back (); 20 21 assert (not src:isnil() and not dst:isnil()) 22 23 -- add "ACE Compressor" to target track 24 local p = ARDOUR.LuaAPI.new_plugin (Session, "urn:ardour:a-comp", ARDOUR.PluginType.LV2, "") 25 assert (not p:isnil ()) 26 27 dst:add_processor_by_index (p, 0, nil, true) 28 ARDOUR.LuaAPI.set_processor_param (p, 1, 300) -- 300ms release time 29 ARDOUR.LuaAPI.set_processor_param (p, 2, 4) -- 4dB Knee 30 ARDOUR.LuaAPI.set_processor_param (p, 3, 7) -- ratio 1:7 31 ARDOUR.LuaAPI.set_processor_param (p, 4, -25) -- threshold -20dBFS 32 ARDOUR.LuaAPI.set_processor_param (p, 9, 1) -- enable sidechain 33 34 -- add Send to src track before the fader 35 local s = ARDOUR.LuaAPI.new_send (Session, src, src:amp ()) 36 assert (not s:isnil ()) 37 38 -- mark as sidechain send 39 local send = s:to_send() 40 send:set_remove_on_disconnect (true) 41 42 -- now connect send to plugin's sidechain input 43 local src_io = send:output() 44 45 -- ACE Compressor already has a sidechain, and sidechain 46 -- pin connected. Other plugins see "plugin channel-map dev" 47 -- snippet how to change plugin pinout. 48 local dst_io = p:to_plugininsert ():sidechain_input () 49 50 src_io:nth(0):connect (dst_io:nth (0):name ()) 51 52end end 53