No internet connection
  1. Home
  2. How to

Create aux, Route and Solo safe Script

By Gabriel Lundh @Gabriel_Lundh
    2021-05-10 10:00:40.118Z

    Hi All!
    I have a few commands that helps me with Aux creation during mixing. The Workflow is basically:

    1. I Select the tracks i want to route and then punch the command
    2. Track output to "new Track"
    3. Specifys the preffered channel width
    4. Waits for me to name the aux
    5. Selects the track created by jumping with P & semicolon.
    6. Solo Safes the new aux

    My problem: More than often the "jumping to the newly created aux" does not work as, depending on the project, Pro Tools Slows down when the aux is being created.
    I wonder if any of you smart people can come up with a way to store the new name that I write in the name box, so that I then can use the "scroll to track" instead and then solo safe?

    I have tried a few options but cannot get around the fact that I only can wait for the New Tracks dialog to disapear, but then its already to late to store then name: Right?

    My script as of now:

    sf.ui.proTools.selectedTrack.trackOutputSelect({
        outputPath: ["new track..."],
        selectForAllSelectedTracks: true,
    });
    
    sf.ui.proTools.windows.whoseTitle.is('New Track').first.elementWaitFor();
    
    sf.ui.proTools.windows.whoseTitle.is('New Track').first.popupButtons.whoseDescription.is('Track format').first.popupMenuSelect({
        menuPath: ["Stereo"],
    });
    
    sf.ui.proTools.windows.whoseTitle.is('New Track').first.popupButtons.whoseDescription.is('Track type').first.popupMenuSelect({
        menuPath: ["Aux Input"],
    });
    
    // Here I want to be able to type the name of the new Aux, thats why I have limitless waiting time
    
    
    sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.elementWaitFor({
        waitType: "Disappear",
        timeout: -1,
    });
    
    sf.wait({
        intervalMs: 2000,
    });
    
    
    sf.keyboard.press({
        keys: "p, semicolon, semicolon",
    });
    
    sf.ui.proTools.selectedTrack.buttons.whoseTitle.is('Solo').first.mouseClickElement({
        isCommand: true,
    });
    
    
    

    Thanks you as always!
    My best,
    Gabriel

    Solved in post #2, click to view
    • 14 replies

    There are 14 replies. Estimated reading time: 22 minutes

    1. samuel henriques @samuel_henriques
        2021-05-10 13:06:57.803Z

        Hello @Gabriel_Lundh,

        Try this.
        The only problem I see here is that, if you cancel the new track window, the script will continue and solo safe the last selected track.
        Let me know how this works for you, and then figure a solution for you.

        sf.ui.proTools.appActivateMainWindow();
        sf.ui.proTools.invalidate();
        
        
        //  Get variable with selected tracks
        const originalSelectedTracks = sf.ui.proTools.selectedTrackNames
        
        //  Get last selected, and popup on that one. This will ensure the new track is allways created after the selected tracks
        const lastSelectedTrack = sf.ui.proTools.trackGetByName({ name: originalSelectedTracks[originalSelectedTracks.length - 1] }).track
        
        //  track Scroll to view
        lastSelectedTrack.trackScrollToView()
        
        // Select all again
        sf.ui.proTools.trackSelectByName({ names: originalSelectedTracks })
        
        // track output popup select, new track
        lastSelectedTrack.trackOutputSelect({
            outputPath: ["new track..."],
            selectForAllSelectedTracks: true,
        });
        
        
        const newTrackWin = sf.ui.proTools.windows.whoseTitle.is('New Track').first.elementWaitFor().element
        
        //  If format is not Stereo, change to Stereo
        if (newTrackWin.popupButtons.allItems[2].invalidate().value.value != "Stereo") {
            newTrackWin.popupButtons.whoseDescription.is('Track format').first.popupMenuSelect({
                menuPath: ["Stereo"],
            });
        }
        //  If type is not Aux Input, change to Aux Input
        if (newTrackWin.popupButtons.first.invalidate().value.value != "Aux Input") {
            newTrackWin.popupButtons.whoseDescription.is('Track type').first.popupMenuSelect({
                menuPath: ["Aux Input"],
            });
        }
        
        // Take your time to type the name of the new Aux.
        
        
        //  Wait forever for new track win to disapper
        newTrackWin.elementWaitFor({ waitType: "Disappear", timeout: -1 });
        
        
        // We just created a new track, so we need souundflow to get this info again
        sf.ui.proTools.invalidate()
        
        //  Get current selected tracks
        const currentSelectedTracks = sf.ui.proTools.selectedTrackNames
        
        // Just to be safe, deselect all tracks
        sf.ui.proTools.trackDeselectAll()
        
        // Get last selected track, should be your new aux
        const newTrack = sf.ui.proTools.trackGetByName({ name: currentSelectedTracks[currentSelectedTracks.length - 1] }).track
        
        //  New track scroll to view
        newTrack.trackScrollToView()
        
        // Solo safe
        newTrack.soloButton.mouseClickElement({ isCommand: true })
        
        
        
        Reply1 LikeSolution
        1. GGabriel Lundh @Gabriel_Lundh
            2021-05-10 13:37:55.307Z

            Hi Samuel!
            I just smiled reading through the script - its so fantastic seeing how all problems can be solved with your brain!
            Works like a charm in PT as well!
            Big thank you for your time Samuel!
            My best,
            Gabriel

            1. AArmand Hirsch @Armand_Hirsch
                2021-11-06 16:18:40.819Z

                This is such a wonderful script! Just one question, trying to modify it so it specifically creates the aux in "bus menu 1-128" , where at the moment it's defaulting to creating the new aux under my master subgroups in bus menu 129-256. I tried a few modifications but wasn't getting anywhere. Any help is much appreciated!!!

                1. samuel henriques @samuel_henriques
                    2021-11-06 20:18:03.499Z

                    Hey Armand,
                    That is something pro tools is managing.
                    The alternative would be to script the change the output path to a specific bus and create a new aux track as so on.

                2. BBenny Turner @Benny_Turner
                    2021-08-05 08:43:59.550Z

                    Hey all, I am very new to SoundFlow, as I in got a Stream Deck a couple of days ago, then discovered SoundFlow and it has now taken over my life :) I am gobsmacked by the sheer scope of the thing.

                    I have started to try to plan out a 'deck' for what I think would really help me every Pro Tools session. I came across your post @Gabriel_Lundh and WOW, I think his is amazing, however, what if I wanted to create an AUX send and route it to the send slot of the revious track?

                    For example, I have a vocal and so would like to create an aux channel for say a reverb but I do not want to route the output of the previous track to the reverb AUX, instead I want to route the SEND of the Vocal to the AUX track but still make is Solo Safe... I hope that makes sense.

                    Would anyone be able to help? As I say, I am a 'noob' and so do not have the skills as yet to know what all the commands mean within the code.

                    Many thanks
                    Benny
                    Peterborough, UK.

                    1. GGabriel Lundh @Gabriel_Lundh
                        2021-08-05 09:26:02.812Z

                        Hi @Benny_Turner !
                        So glad you joined the crew - SF takes over all our lives (and makes it SO MUCH more fun to work)!
                        Great question: I took Samuels script from above and combined it with a previous script he helped me make.
                        So I have a few versions that helps me out in everyday life.

                        1. Finding the first available send slot, Creating a new AUX with desired channel width, Waiting for me to write the name of the new AUX, Solosafes the new AUX, Finds the first available insert slot and clicks SEARCH, so that I can write the name of the plugin I want on the AUX and be up and running in a flash.
                          Here is that script for Stereo Aux (just change the width in the script for a mono version):
                        sf.ui.proTools.appActivateMainWindow();
                        sf.ui.proTools.invalidate();
                        
                        
                        //  Get variable with selected tracks
                        const originalSelectedTracks = sf.ui.proTools.selectedTrackNames
                        
                        //  Get last selected, and popup on that one. This will ensure the new track is allways created after the selected tracks
                        const lastSelectedTrack = sf.ui.proTools.trackGetByName({ name: originalSelectedTracks[originalSelectedTracks.length - 1] }).track
                        
                        //  track Scroll to view
                        lastSelectedTrack.trackScrollToView()
                        
                        // Select all again
                        sf.ui.proTools.trackSelectByName({ names: originalSelectedTracks })
                        
                        // Make sure we're on the Edit window.
                        if (!sf.ui.proTools.getMenuItem("Window", "Edit").isMenuChecked) {
                            sf.ui.proTools.menuClick({ menuPath: ["Window", "Edit"], });
                            // Scroll to avoid error
                            sf.ui.proTools.selectedTrack.trackScrollToView();
                        };
                        
                        function getFirstFreeSendIndex() {
                            let btns = sf.ui.proTools.selectedTrack.invalidate().sendButtons;
                            for (let i = 0; i < 10; i++)
                                if (btns[i].value.invalidate().value === "unassigned") return i;
                            return -1;
                        };
                        
                        let sends = getFirstFreeSendIndex() < 5 ? "Sends A-E" : "Sends F-J";
                        
                        const sendLetter = 'ABCDEFGHIJ';
                        
                        const popupMenu = sf.ui.proTools.selectedTrack.groups.whoseTitle.is(sends).first.buttons.
                            whoseTitle.is("Send selector " + sendLetter[getFirstFreeSendIndex()]).first.popupMenuOpenFromElement().popupMenu;
                        
                        popupMenu.menuClickPopupMenu({ menuPath: ['new track...'], });
                        
                        
                        
                        
                        const newTrackWin = sf.ui.proTools.windows.whoseTitle.is('New Track').first.elementWaitFor().element
                        
                        //  If format is not Stereo, change to Stereo
                        if (newTrackWin.popupButtons.allItems[2].invalidate().value.value != "Stereo") {
                            newTrackWin.popupButtons.whoseDescription.is('Track format').first.popupMenuSelect({
                                menuPath: ["Stereo"],
                            });
                        }
                        //  If type is not Aux Input, change to Aux Input
                        if (newTrackWin.popupButtons.first.invalidate().value.value != "Aux Input") {
                            newTrackWin.popupButtons.whoseDescription.is('Track type').first.popupMenuSelect({
                                menuPath: ["Aux Input"],
                            });
                        }
                        
                        // Take your time to type the name of the new Aux.
                        
                        
                        //  Wait forever for new track win to disapper
                        newTrackWin.elementWaitFor({ waitType: "Disappear", timeout: -1 });
                        
                        
                        // We just created a new track, so we need souundflow to get this info again
                        sf.ui.proTools.invalidate()
                        
                        //  Get current selected tracks
                        const currentSelectedTracks = sf.ui.proTools.selectedTrackNames
                        
                        // Just to be safe, deselect all tracks
                        sf.ui.proTools.trackDeselectAll()
                        
                        // Get last selected track, should be your new aux
                        const newTrack = sf.ui.proTools.trackGetByName({ name: currentSelectedTracks[currentSelectedTracks.length - 1] }).track
                        
                        //  New track scroll to view
                        newTrack.trackScrollToView()
                        
                        // Solo safe
                        newTrack.soloButton.mouseClickElement({ isCommand: true })
                        
                        function getFirstFreeInsertIndex() {
                            let btns = sf.ui.proTools.selectedTrack.invalidate().insertButtons;
                            for (let i = 0; i < 10; i++)
                                if (btns[i].value.invalidate().value === "unassigned") return i;
                            return -1;
                        };
                        
                        let inserts = getFirstFreeInsertIndex() < 5 ? "Inserts A-E" : "Inserts F-J";
                        
                        const insertLetter = 'ABCDEFGHIJ';
                        
                        const popupMenu = sf.ui.proTools.selectedTrack.groups.whoseTitle.is(inserts).first.buttons.
                            whoseTitle.is("Insert selector " + insertLetter[getFirstFreeInsertIndex()]).first.popupMenuOpenFromElement().popupMenu;
                        
                        popupMenu.menuClickPopupMenu({ menuPath: ['search...'], });
                        

                        I have one for mono and one for stereo. Also have a few versions of width for track output creation.
                        Just let me know if you need any adaption help - this script is so valuble - Thanks again @samuel_henriques !

                        All the best,
                        Gabriel

                        1. Dana Nielsen @Dana_Nielsen
                            2022-03-23 21:06:58.587Z

                            Thanks so much for this script @Gabriel_Lundh and @samuel_henriques !!!! I've been needing this in my life for decades lol. The final missing link for me is the best way to assign the ouput of the newly created Aux Input to the same output as the "source track" from which I'm sending. Any ideas? In other words: the new Aux Input defaults to my "default output routing" (in my case 1-2). The source track I'm sending from however (Piano for example), is outputing to my "KEYS" buss submaster. So I'm trying to figure out the best way to copy the output routing of the Piano track(s) I've run the script on (or perhaps the "last selected track" when running the script) and apply that output routing to the new Aux Input, maybe before or after the "solo safe" happens? THANKS SO MUCH for any/all advice!!!!

                            1. GGabriel Lundh @Gabriel_Lundh
                                2022-03-23 22:14:20.870Z2022-03-24 09:27:56.172Z

                                Hi @Dana_Nielsen !
                                So glad you are using the script!!
                                I stole a bit of code from the genius mr.Scheps and came up with this:

                                sf.ui.proTools.appActivateMainWindow();
                                sf.ui.proTools.invalidate();
                                
                                
                                //  Get variable with selected tracks
                                const originalSelectedTracks = sf.ui.proTools.selectedTrackNames
                                // Set up variables to hold original assignments. NOTE this will only check the top-most selected track
                                //Variable to store the current output assignment
                                var originalOutput = sf.ui.proTools.selectedTrack.outputPathButton.value.invalidate().value;
                                
                                //  Get last selected, and popup on that one. This will ensure the new track is allways created after the selected tracks
                                const lastSelectedTrack = sf.ui.proTools.trackGetByName({ name: originalSelectedTracks[originalSelectedTracks.length - 1] }).track
                                
                                //  track Scroll to view
                                lastSelectedTrack.trackScrollToView()
                                
                                // Select all again
                                sf.ui.proTools.trackSelectByName({ names: originalSelectedTracks })
                                
                                // Make sure we're on the Edit window.
                                if (!sf.ui.proTools.getMenuItem("Window", "Edit").isMenuChecked) {
                                    sf.ui.proTools.menuClick({ menuPath: ["Window", "Edit"], });
                                    // Scroll to avoid error
                                    sf.ui.proTools.selectedTrack.trackScrollToView();
                                };
                                
                                function getFirstFreeSendIndex() {
                                    let btns = sf.ui.proTools.selectedTrack.invalidate().sendButtons;
                                    for (let i = 0; i < 10; i++)
                                        if (btns[i].value.invalidate().value === "unassigned") return i;
                                    return -1;
                                };
                                
                                let sends = getFirstFreeSendIndex() < 5 ? "Sends A-E" : "Sends F-J";
                                
                                const sendLetter = 'ABCDEFGHIJ';
                                
                                const popupMenu = sf.ui.proTools.selectedTrack.groups.whoseTitle.is(sends).first.buttons.
                                    whoseTitle.is("Send selector " + sendLetter[getFirstFreeSendIndex()]).first.popupMenuOpenFromElement().popupMenu;
                                
                                popupMenu.menuClickPopupMenu({ menuPath: ['new track...'], });
                                
                                
                                
                                
                                const newTrackWin = sf.ui.proTools.windows.whoseTitle.is('New Track').first.elementWaitFor().element
                                
                                //  If format is not Stereo, change to Stereo
                                if (newTrackWin.popupButtons.allItems[2].invalidate().value.value != "Stereo") {
                                    newTrackWin.popupButtons.whoseDescription.is('Track format').first.popupMenuSelect({
                                        menuPath: ["Stereo"],
                                    });
                                }
                                //  If type is not Aux Input, change to Aux Input
                                if (newTrackWin.popupButtons.first.invalidate().value.value != "Aux Input") {
                                    newTrackWin.popupButtons.whoseDescription.is('Track type').first.popupMenuSelect({
                                        menuPath: ["Aux Input"],
                                    });
                                }
                                
                                // Take your time to type the name of the new Aux.
                                
                                
                                //  Wait forever for new track win to disapper
                                newTrackWin.elementWaitFor({ waitType: "Disappear", timeout: -1 });
                                
                                
                                // We just created a new track, so we need souundflow to get this info again
                                sf.ui.proTools.invalidate()
                                
                                //  Get current selected tracks
                                const currentSelectedTracks = sf.ui.proTools.selectedTrackNames
                                
                                // Just to be safe, deselect all tracks
                                sf.ui.proTools.trackDeselectAll()
                                
                                // Get last selected track, should be your new aux
                                const newTrack = sf.ui.proTools.trackGetByName({ name: currentSelectedTracks[currentSelectedTracks.length - 1] }).track
                                
                                //  New track scroll to view
                                newTrack.trackScrollToView()
                                
                                // Solo safe
                                newTrack.soloButton.mouseClickElement({ isCommand: true })
                                
                                if (originalOutput !== "MIX") {
                                    sf.ui.proTools.selectedTrack.trackOutputSelect({
                                        outputSelector: items => items.filter(item => item.path[0] === "bus" && item.path.slice(-1)[0] === originalOutput + " (Stereo)")[0],
                                        //skipWhenValueIs: 'Mix Buss',
                                        selectForAllSelectedTracks: true,
                                    }, function (wasHardware) {
                                        log( "Original output was Hardware");
                                    });
                                }
                                
                                function getFirstFreeInsertIndex() {
                                    let btns = sf.ui.proTools.selectedTrack.invalidate().insertButtons;
                                    for (let i = 0; i < 10; i++)
                                        if (btns[i].value.invalidate().value === "unassigned") return i;
                                    return -1;
                                };
                                
                                let inserts = getFirstFreeInsertIndex() < 5 ? "Inserts A-E" : "Inserts F-J";
                                
                                const insertLetter = 'ABCDEFGHIJ';
                                
                                const popupMenu = sf.ui.proTools.selectedTrack.groups.whoseTitle.is(inserts).first.buttons.
                                    whoseTitle.is("Insert selector " + insertLetter[getFirstFreeInsertIndex()]).first.popupMenuOpenFromElement().popupMenu;
                                    
                                popupMenu.menuClickPopupMenu({ menuPath: ['search...'], });
                                
                                

                                Great addition to the script, thank you for the idea!
                                Just a heads up - this code only works if the original output of the source track is a bus and not Hardware (ie. 1-2). So it should work well for most use cases.

                                Hope it helps!

                                1. Dana Nielsen @Dana_Nielsen
                                    2022-03-24 01:24:06.753Z

                                    @Gabriel_Lundh !!! OMGOMGOMGOMGOMGOMG!!! This is freaking BRILLIANT!!! Thank you and that dang genius and dear friend @Andrew_Scheps. This is so awesome, thank you so much for your help!! It worked perfectly! (For anyone reading along and copying from above, I think the script got duplicated a few times (?) so I ended up pasting lines 1 through 110 and it worked great!).

                                    One quick observation FWIW, the script doesn't seem to like it when I have my edit window sends in "fader mode" which I'm prone to do. You know ... command click on send A and you get the mini fader and pan pots? But when I command click to collapse them back so that all 5 (or 10) send slots are visible, it works like a charm.

                                    GENIUS!!! Thank u thank u thank u!
                                    Best,

                                    Dana

                                    1. GGabriel Lundh @Gabriel_Lundh
                                        2022-03-24 09:29:28.533Z

                                        Hi @Dana_Nielsen !! So glad it worked and that you saw that the script was duplicated - it was late here, so did not read through the post properly, haha!
                                        Now I've edited the post so eventual new readers can copy and use.

                                        Hope you have a fantastic weekend!!
                                        All the best,
                                        Gabriel

                                        1. Dana Nielsen @Dana_Nielsen
                                            2022-03-24 16:06:09.459Z

                                            Amazing! Thanks, @Gabriel_Lundh, you too!!

                              • P
                                In reply toGabriel_Lundh:
                                Philip weinrobe @Philip_weinrobe
                                  2021-09-11 16:59:15.976Z

                                  hi all! i'm new here and trying to do exactly what this script does! the earlier versions posted in this thread work great for creating simple routed outputs to an aux.

                                  this more elaborate "create send" script is exactly what i need, but it is doing something weird on my end. it is only making the send from the first selected track and placing the plugin on the last selected audio track. only the first selected audio track is actually being routed to the newly created aux.

                                  i can't figure out how to edit the script to fix this. any help appreciated!

                                  1. M
                                    In reply toGabriel_Lundh:
                                    Matt Cahill @Matt_Cahill
                                      2023-01-12 15:12:05.305Z

                                      Hi guys,

                                      Loooooove love love this script but it's not solo safing the new Aux for me?? anyone else getting the same problem?

                                      cheers

                                      1. QQuirijn Vos @Quirijn_Vos
                                          2023-07-10 20:16:27.725Z

                                          Really amazing script this saved me sooo much time!
                                          Unfortunately I have the same issue that it will not solo safe