Created
March 1, 2026 16:02
-
-
Save x42/3004bf753de4877a7fd78e7f9d0bb110 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ardour { | |
| ["type"] = "EditorAction", | |
| name = "Set I/O config", | |
| license = "MIT", | |
| author = "Robin Gareus, Wargreen", | |
| description = [[Set a custom track I/O configuration]] | |
| } | |
| function factory(unused_params) | |
| return function() | |
| local inputs = 2 | |
| local outputs = 2 | |
| local dialog_options = { | |
| { type = "number", key = "inputs", title = "Number of inputs", min = 1, max = 64, step = 1, digits = 0, default = inputs }, | |
| { type = "number", key = "outputs", title = "Number of outputs", min = 1, max = 64, step = 1, digits = 0, default = outputs }, | |
| } | |
| local rv = LuaDialog.Dialog("Select number of ports", dialog_options):run() | |
| -- Return if the user cancelled | |
| if not rv then | |
| inputs, outputs = nil, nil | |
| return | |
| end | |
| local target_in = rv["inputs"] | |
| local target_out = rv["outputs"] | |
| -- get Editor selection: | |
| sel = Editor:get_selection () | |
| -- for each selected track/bus | |
| for route in sel.tracks:routelist ():iter () do | |
| print (route:name()) | |
| -- unset strict io if needeed | |
| if target_in ~= target_out then | |
| route:set_strict_io (false) | |
| end | |
| -- process input | |
| local i = route:input () | |
| local nbr_iports = i:n_ports ():n_audio () | |
| print ("Process add in") | |
| if target_in > nbr_iports then | |
| local to_add = target_in - nbr_iports | |
| for n = 1, to_add do | |
| i:add_port ("", nil, ARDOUR.DataType ("Audio")) | |
| end | |
| end | |
| print ("Process remove in") | |
| if target_in < nbr_iports then | |
| for n = nbr_iports - 1, target_in do | |
| print ("REMOVE", n) | |
| if not i:nth(n):isnil() then | |
| i:remove_port (i:nth(n), nil) | |
| end | |
| end | |
| end | |
| -- process output | |
| local o = route:output () | |
| local nbr_oports = o:n_ports ():n_audio () | |
| print ("Process add out") | |
| if target_out > nbr_oports then | |
| local to_add = target_out - nbr_oports | |
| for n = 1, to_add do | |
| o:add_port ("", nil, ARDOUR.DataType ("Audio")) | |
| end | |
| end | |
| print ("Process remove out") | |
| if target_out < nbr_oports then | |
| for n = nbr_iports - 1, target_out do | |
| if not o:nth(n):isnil() then | |
| o:remove_port (o:nth(n), nil) | |
| end | |
| end | |
| end | |
| end -- for each track | |
| end end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment