Lua: disable output autoconnect

I know how to create a new audio track with new_audio_track () and I already found out, that you can enable or disable the input autoconnect option with it’s penultimate parameter.
But how can I avoid the new track to autoconnect it’s output to the master?
I found, there’s a set_output_auto_connect () method, but I couldn’t figure out, how to apply it 'til now. :frowning:

Got it:

set_output_auto_connect() is an ARDOUR.config() method and therefore corresponds to something in the Preferences (usually). In this case Signal Flow > Connect track and bus outputs.

Turning that setting ‘off’ (“manual”) before creating the track will achieve what you want. To be a good citizen the script should then put the setting back to what it was - scripts changing a user’s Preferences will not go down well.

--grab the current value of the output-auto-connect config setting
local oac = ARDOUR.config():get_output_auto_connect()

--turn off output-auto-connect

--...create route here...

--put the setting back to what it was 

Alternatively, script could disconnect the route’s output ports from the Master input ports:

--where r is a route

Note that this disconnects the out ports from everything, not just the Master. E.g. If it was also connected to the inputs of another route, say a bus, then that connection will be removed as well. If it’s a new route then it will not have any such connections, unless script has created any. A function could be written that only disconnects from the Master.

I would do it this way. With the config() way there is a risk that the setting isn’t put back to what it was. E.g. the create-route step throws an error for some reason, breaking the script, so no script beyond that line is run. Re-running the script won’t fix that problem.


Yeah, that’s exactly how I’ve done it, after I figured out, how set_output_auto_connect() works! :slight_smile:

That’s a good point I didn’t even think of! I already had a solution before, where I disconnected all master inputs via for-loops, but I discarded it, because I thought, this was to laborious and the above solution saves quite a couple of code-lines. But maybe I have to come back to it… :thinking:

Here’s a disconnect-only-from-Master solution, plus a more general helper function.

---Disconnects fromRoute's output ports from toRoute's input ports.
---@param fromRoute ARDOUR.Route
---@param toRoute ARDOUR.Route
function disconnectRoutes(fromRoute, toRoute)
  for i = 0, fromRoute:output():n_ports():n_total() - 1 do
    local fromPort = fromRoute:output():nth(i)
    for j = 0, toRoute:input():n_ports():n_total() - 1 do

---Disconnects fromRoute's output ports from the Master's input ports.
---@param fromRoute ARDOUR.Route
function disconnectFromMaster(fromRoute)
  disconnectRoutes(fromRoute, Session:master_out())

In Mixbus, routes are connected to the Master in a different way; all of the script in this thread has no effect there. Instead script must call :master_send_enable_controllable():set_value() on the route. Just thought I’d mention that, if Mixbus compatibility is ever needed.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.