No internet connection
  1. Home
  2. Script Sharing

Solo [Solo-Safed] AUX Tracks

By Tristan Hoogland @Tristan
    2022-12-25 00:42:41.104Z

    Hey team,

    Merry Christmas eve. I just published this script on my page, but I thought I'd share it here for feedback. It's also one of my first stints with using json files, which was surprisingly a lot easier to do than I thought. I'm not sure if there's a better way to do this, the json seemed the best. @Kitch ?

    In an effort to overcome ProTools' lack of functionality on this front here's a handy package that affords you the ability to solo AUX tracks that are solo safed. A typical case where this is useful: You have a series of tracks feeding a master Drum AUX that, like most people, have solo safed so you can solo individual elements within the tracks that feed that AUX. You want to solo the drums as a whole, but you can't just simply click solo on the Drum AUX - you need to either mute everything else, scroll to and solo the actual audio tracks that comprimse of the drums, potentially group them to solo them altogether, invert the solos so the audio tracks are solo safed, but not the AUX. The workflow of nightmares amirite?!

    It's currently broken down into two functions, one that stores the tracks into the json file using one key-command/trigger and another that recalls them with a separate key-command/trigger.

    How to use
    There are two scripts as part of this package, one to store the AUX and its corresponding audio tracks and another to recall them. They both need to be assigned individual commands or buttons to work. You can use whatever you want, but I use the following:
    Store - CTRL+Option+S
    Recall/Solo AUX - Ctrl+S
    I use these because it closely mimics "Shift+S" which is the PT default for soloing a selected track.
    Part 1: Store Tracks
    Select just the AUX you want to be able to be able to solo (no audio tracks). Then run the corresponding Store Tracks function whether that be with your key commands or streamdeck.
    Part 2: Recall/Solo Tracks
    Now whenever you want to solo that AUX you simply select that track, and it'll solo the other tracks for you.
    Features/Notes:
    This creates and stores a JSON file in your session folder, which keeps a log of the tracks needing solo'ing.
    The way it operates is it checks for all tracks assigned to an AUX
    The script is additive, once you've stored an AUX you can continue to add, create and update groups as you work. Simply use the Store Tracks function whenever you need to.

    Script 1 - Store Tracks

    //Session Files and Folders
    const sessionPath = sf.ui.proTools.mainWindow.invalidate().sessionPath;
    const sessionDirectory = sessionPath.split('/').slice(0, -1).join('/');
    const sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
    
    //Create JSON file directory within session folder structure
    const JSON_DIR = `${sessionDirectory}/SoundflowSoloAuxJson`;
    
    //check for and or create folder as listed above
    sf.system.exec({ commandLine: 'mkdir -p "' + JSON_DIR + '"' });
    
    const auxTrackToSolo = [];
    
    //Get the current window name
    const focusedWindow = sf.ui.proTools.focusedWindow.title.invalidate().value.split(" ", 1)[0].slice(0, -1);
    
    //If not already in the Edit window, switch to the Edit window
    if (focusedWindow !== 'Edit') {
        sf.ui.proTools.menuClick({ menuPath: ['Window', 'Edit'] });
    }
    
    const selectedAuxMasterTrack = sf.ui.proTools.selectedTrackNames;
    auxTrackToSolo.push(selectedAuxMasterTrack[0])
    
    sf.ui.proTools.selectedTrack.inputPathButton.popupMenuSelect({
      isRightClick: true,
      menuPath: ["Select Assignments to*"],
      useWildcards: true
    });
    
    let tracksToStore = sf.ui.proTools.selectedTrackNames;
    
    if (!sf.file.exists({ path: JSON_DIR + '/storeSelectedTracks.json' }).exists) {
      sf.file.writeJson({ path: JSON_DIR + '/storeSelectedTracks.json', json: {} });
    }
    
    // Read the existing JSON file
    const jsonData = sf.file.readJson({ path: JSON_DIR + '/storeSelectedTracks.json' }).json;
    
    // Update the tracks in the file
    jsonData[selectedAuxMasterTrack[0]] = {
      auxTrackToSolo,
      tracksToStore,
    };
    
    // Write the updated tracks selection
    sf.file.writeJson({ path: JSON_DIR + '/storeSelectedTracks.json', json: jsonData });
    
    sf.ui.proTools.trackDeselectAll();
    sf.ui.proTools.trackGetByName({ name: auxTrackToSolo[0] }).track.trackSelect();
    
    //Switch back to Mix window if needed.
    if (focusedWindow !== "Edit") {
        sf.ui.proTools.menuClick({ menuPath: ['Window', 'Mix'] });
    }
    

    Script 2 (Recall/Solo AUX)

    //Session Files and Folders
    const sessionPath = sf.ui.proTools.mainWindow.invalidate().sessionPath;
    const sessionDirectory = sessionPath.split('/').slice(0, -1).join('/');
    const sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
    
    //Create JSON file directory within session folder structure
    const JSON_DIR = `${sessionDirectory}/SoundflowSoloAuxJson`;
    
    sf.ui.proTools.invalidate();
    
    //check current solo mode
    const soloMode = sf.ui.proTools.getMenuItem('Options', 'Solo Mode', 'Latch').isMenuChecked
    
    //if solo mode isn't on latch, put on latch
    if (soloMode !== true) {
        sf.ui.proTools.menuClick({ menuPath: ['Options', 'Solo Mode', 'Latch'] });
    }
    
    // Read the contents of JSON
    if (!sf.file.exists({ path: JSON_DIR + '/storeSelectedTracks.json' }).exists) {
        log("No JSON file found for this session, be sure to store tracks with the other package and try again")
        throw 0
    }
    const storeSelectedTracks = sf.file.readJson({ path: JSON_DIR + '/storeSelectedTracks.json' }).json;
    
    const selectedTrack = sf.ui.proTools.selectedTrackNames[0]
    
    if (storeSelectedTracks[selectedTrack]) {
        // Access the stored tracks for the selected track
        const storedTracks = storeSelectedTracks[selectedTrack].tracksToStore;
    
        // Solo the stored tracks
        storedTracks.forEach((trackName) => {
            sf.ui.proTools.trackSetSoloByName({ name: trackName });
        });
    }
    
    //put solo mode back to X-OR
    if (soloMode !== false) {
        sf.ui.proTools.menuClick({ menuPath: ['Options', 'Solo Mode', 'X-OR (Cancels Previous Solo)'] });
    }
    
    • 6 replies
    1. T
      Tristan Hoogland @Tristan
        2022-12-25 00:44:51.210Z

        @Kitch I'd love for your help on determining the solo states before running the script and then returning it to whatever that solo state is after. It needs to use latch to do the soloing part, but I always have my solo state in X-OR mode as standard.

        1. Brenden @nednednerb
            2022-12-25 08:42:59.993Z

            Script looks cool, and useful when mixing different parts of a song!!!

            Hopefully Kitch is warm and distracted from work ;)

            However, I heard him talking about this once, and I recalled the thread to look it up!!

            1. TTristan Hoogland @Tristan
                2022-12-25 17:42:34.089Z

                I love these old posts. I knew it'd be tucked in there somewhere!

              • In reply toTristan:
                Kitch Membery @Kitch2022-12-25 10:27:17.403Z

                Will take a look in the next few days man. But looks cool!

              • In reply toTristan:
                Kitch Membery @Kitch2022-12-26 02:37:46.086Z

                Merry Christmas @Tristan!!!

                Here is the way to get the current menu solo modes (There are 2 modes selectable from the "Options"=>"Solo Mode" menu).

                This will get the modes;

                const AVAILALE_SOLO_MODES = [
                    "SIP (Solo In Place)",
                    "AFL (After Fader Listen)",
                    "PFL (Pre Fader Listen)",
                    "Latch",
                    "X-OR (Cancels Previous Solo)",
                    "Momentary"
                ];
                
                //Get the solo modes from the "Options", "Solo" mode
                const oldSoloModes = AVAILALE_SOLO_MODES.filter(mode => sf.ui.proTools.getMenuItem("Options", "Solo Mode", mode).isMenuChecked);
                
                log(oldSoloModes);
                

                And this will restore them

                //Restore Solo Modes
                oldSoloModes.forEach(mode => sf.ui.proTools.menuClick({ menuPath: ["Options", "Solo Mode", mode] }));
                

                You can also get the Solo information from the selected tracks you could map the tracks like this.

                const selectedTracks = sf.ui.proTools.selectedTrackHeaders;
                
                const trackInfo = selectedTracks.map(track => ({
                    name: track.normalizedTrackName,
                    soloRestoreValue: track.soloButton && track.soloButton.value.invalidate().value === "on" ? "Enable" : "Disable",
                }));
                

                And then you could restore them like this.

                sf.ui.proTools.appActivateMainWindow();
                
                //For each track restore the solo state
                trackInfo.forEach(track => {
                    sf.ui.proTools.trackSetSoloByName({
                        name: track.name,
                        /* @ts-ignore */
                        targetValue: track.soloRestoreValue,
                    });
                });
                

                If there are mistakes in this code blame it on the ghost of Christmas preset!

                1. In reply toTristan:
                  Kitch Membery @Kitch2022-12-26 02:40:37.536Z

                  Let me know if you get stuck with storing/recalling the JSON structure. :-)