Request for help: lua script to disconnect metronome

I prefer a click track, so I connect the metronome to it, but on start up the metronome is always re-connected to the direct out. (ambiguous latency)

Could someone familiar with Lua than me be kind enough to post a snippet that I can run at startup?

This worked for me:

ardour { ["type"] = "Snippet", name = "disconnect_click" }

function factory () return function ()
    local a = Session:engine()

    -- Get all audio output ports
    _, t = a:get_backend_ports ("", ARDOUR.DataType("audio"), ARDOUR.PortFlags.IsOutput, C.StringVector())

    for n in t[4]:iter() do
        if n:find("Click/audio_out") then
            print("Disconnecting", n)
            
            -- Get current connections for this port
            local _, ct = a:get_connections(n, C.StringVector())

            -- Disconnect each connected port
            for c in ct[2]:iter() do
                print(" -> Disconnecting from", c)
                a:disconnect(n, c)
            end
        end
    end

    print("Click outputs disconnected.")
end end

1 Like

Thanks mate, I owe you one!