No internet connection
  1. Home
  2. How to

Panning multiple selected tracks Left and Right

By Michael Ubinas @Michael_Ubinas
    2024-02-20 16:59:33.611Z

    Hey everyone. I'm trying to make a script where I can select multiple tracks, and then have soundflow go through the tracks and pan the first one to the left, the second to the right, third left, fourth right, and so on. Is there a script that allows me to switch through two (or more maybe) different actions as it cycles through each selected track? I'm currently just trying to use this to hard pan a bunch of BGV tracks, but I know there will be plenty of other useful applications if this is possible. Thanks!

    • 5 replies
    1. Nathan Salefski @nathansalefski
        2024-02-20 18:21:20.878Z

        Try this out:

        function panTrack(trackName, panValue) {
            sf.ui.proTools.trackSelectByName({ names: [trackName] });
        
            sf.ui.proTools.selectedTrack.outputWindowButton.elementClick({ executionMode: 'Background' });
        
            sf.ui.proTools.mainTrackOutputWindow.elementWaitFor();
        
            sf.ui.proTools.mainTrackOutputWindow.textFields[1].elementClick();
        
            sf.keyboard.type({
                text: panValue
            });
        
            sf.keyboard.press({
                keys: 'return'
            });
        
            sf.ui.proTools.mainTrackOutputWindow.windowClose();
        
            sf.ui.proTools.mainTrackOutputWindow.elementWaitFor({
                waitType: 'Disappear'
            });
        }
        
        function main() {
            sf.ui.proTools.appActivateMainWindow();
            sf.ui.proTools.mainWindow.invalidate();
        
            let selectedTracks = sf.ui.proTools.selectedTrackNames;
        
            selectedTracks.forEach((trackName, trackNameIndex) => {
                if (trackNameIndex % 2 == 0) {
                    panTrack(trackName, '-100');
                } else {
                    panTrack(trackName, '100');
                }
            });
        
            sf.ui.proTools.trackSelectByName({names: selectedTracks});
        }
        
        main();
        
        1. MMichael Ubinas @Michael_Ubinas
            2024-02-20 21:27:09.963Z

            Awesome, that works perfectly! Thank you so much. One more quick question. So I have this script that I found here on the forum that changes the panning and works on both mono and stereo tracks. I was trying to combine the two, but I think I just don't know enough about scripting yet lol. I thought it would work if I replaced the "panTrack(trackName, '-100');" with it but it just changes the panning of the first track multiple times and then stops. How can I integrate the two scripts? Here it is

            sf.ui.proTools.appActivateMainWindow();
            
            var wasOpen = sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value === 'open';
            
            if (sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value !== 'open')
            
            
                sf.ui.proTools.selectedTrack.trackOutputToggleShow();
            
            if (sf.ui.proTools.mainTrackOutputWindow.buttons.whoseTitle.is('Link').exists) {
                sf.ui.proTools.mainTrackOutputWindow.textFields.whoseTitle.is('Front Pan Numerical').first.elementWaitFor();
            
                //sf.ui.proTools.mainTrackOutputWindow.buttons.whoseTitle.is('Link').first.elementClick(); */
            
                //sf.ui.proTools.mainTrackOutputWindow.buttons.whoseTitle.is('Inverse Pan').first.elementClick(); */
            
                sf.ui.proTools.mainTrackOutputWindow.textFields.whoseTitle.is('Front Pan Numerical').first.elementClick();
            
                sf.keyboard.type({
                    text: "-100",
                });
            
                sf.keyboard.press({
                    keys: "numpad enter",
                });
            
                sf.ui.proTools.mainTrackOutputWindow.textFields.whoseTitle.is('Front Pan Numerical').allItems[1].elementClick();
            
                sf.keyboard.type({
                    text: "-100",
                });
            
                sf.keyboard.press({
                    keys: "numpad enter",
                });
            
                if (!wasOpen) {
                    sf.ui.proTools.mainTrackOutputWindow.getElement('AXCloseButton').elementClick();
            
                    sf.ui.proTools.mainTrackOutputWindow.groups.whoseTitle.is('LEAD_1 - Audio Track ').first.elementWaitFor({
                        waitType: "Disappear",
                    });
                }
            
            }
            
            
            else {
                sf.ui.proTools.mainTrackOutputWindow.textFields.whoseTitle.is('Front Pan Numerical').first.elementWaitFor();
            
                sf.ui.proTools.mainTrackOutputWindow.textFields.whoseTitle.is('Front Pan Numerical').first.elementClick();
            
                sf.keyboard.type({
                    text: "-100",
                });
            
                sf.keyboard.press({
                    keys: "numpad enter",
                });
            
            
                if (!wasOpen) {
                    sf.ui.proTools.mainTrackOutputWindow.getElement('AXCloseButton').elementClick();
            
                    sf.ui.proTools.mainTrackOutputWindow.groups.whoseTitle.is('LEAD_1 - Audio Track ').first.elementWaitFor({
                        waitType: "Disappear",
                    });
                }
            }
            
            1. Nathan Salefski @nathansalefski
                2024-02-20 22:42:57.155Z

                Try this:

                function panTrack(num, panValue) {
                    sf.ui.proTools.selectedTrack.outputWindowButton.elementClick({ executionMode: 'Background' });
                
                    sf.ui.proTools.mainTrackOutputWindow.elementWaitFor();
                
                    sf.ui.proTools.mainTrackOutputWindow.textFields[num].elementClick();
                
                    sf.keyboard.type({
                        text: panValue
                    });
                
                    sf.keyboard.press({
                        keys: 'return'
                    });
                
                    sf.ui.proTools.mainTrackOutputWindow.windowClose();
                
                    sf.ui.proTools.mainTrackOutputWindow.elementWaitFor({
                        waitType: 'Disappear'
                    });
                }
                
                function main() {
                    sf.ui.proTools.appActivateMainWindow();
                    sf.ui.proTools.mainWindow.invalidate();
                
                    let selectedTracks = sf.ui.proTools.selectedTrackNames;
                
                    selectedTracks.forEach((trackName, trackNameIndex) => {
                        if (trackNameIndex % 2 == 0) {
                            sf.ui.proTools.trackSelectByName({ names: [trackName] });
                
                            const selectedTrack = sf.ui.proTools.selectedTrack;
                            const iOGroup = selectedTrack.groups.whoseTitle.is('Audio IO');
                            const panPot = iOGroup.first.sliders.whoseTitle.contains('Pan');
                
                            if (panPot.count == 1) {
                                panTrack(1, '-100');
                            } else {
                                panTrack(2, '-100')
                            }
                        } else {
                            sf.ui.proTools.trackSelectByName({ names: [trackName] });
                
                            panTrack(1, '100');
                        }
                    });
                
                    sf.ui.proTools.trackSelectByName({ names: selectedTracks });
                }
                
                main();
                
                1. MMichael Ubinas @Michael_Ubinas
                    2024-05-24 04:55:43.022Z

                    So sorry for just now replying back to you, but I wanted to come back and say thank you! It works perfectly. Super helpful.

              • J
                In reply toMichael_Ubinas:
                Johannes Häger @Johannes_Hager
                  2024-11-06 08:33:23.785Z

                  This was great, thanks! Is there a way to include more than two panning values? E.g. selecting 4 tracks changes the panning to -100, -50, 50 and 100? Would be great when dealing with a lot of backing vocals tracks!