No internet connection
  1. Home
  2. How to

Set All Tracks To Small Height & Waveform View

I am trying to add to this script that sets all tracks to small height so that it also sets all tracks to waveform view. But haven't been able to figure out how to select waveform for all tracks. Here's the script:

sf.ui.proTools.appActivate();
var sizes = ['small'];
// var sizes = ['small', 'medium', 'large'];

if (globalState.csTrackSize == undefined) { globalState.csTrackSize = 1 };
globalState.csTrackSize++;
if (globalState.csTrackSize >= sizes.length) { globalState.csTrackSize = 0 };
try {
var f = sf.ui.proTools.selectedTrack.frame;
var popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({
relativePosition: { x: f.w - 10, y: 5 },
isOption: true,
isShift: (event.keyboardState.hasAlt) ? true : false,
}).popupMenu;
popupMenu.menuClickPopupMenu({
menuPath: [sizes[globalState.csTrackSize]]
});

} catch (err) { };

  • 23 replies

There are 23 replies. Estimated reading time: 16 minutes

  1. Hey Steve!

    You can do so by adding the following before the last line of your script:

    sf.ui.proTools.selectedTrack.displaySelectorButton.popupMenuSelect({
        isOption: true,
        isShift: true,
        menuPath: ['waveform']
    });
    
    1. Hi Raphael! Hmm...it's only selecting one track to set to waveform view, not all tracks.

      1. Ah, I see what's happening. I went ahead and refactored the entire script, that way I'm sure it'll work right!

        function determineTopMostEditTrack() {
            sf.ui.proTools.mainWindow.invalidate();
            const editTimeLineTopY = sf.ui.proTools.mainWindow.timelineFocusButton.frame.y;
            const topTrack = sf.ui.proTools.visibleTrackHeaders.filter(h => h.frame.y >= editTimeLineTopY)[0];
            return topTrack;
        };
        
        function resizeTracks({ size }) {
            const f = sf.ui.proTools.selectedTrack.frame;
            const popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({
                relativePosition: { x: f.w - 10, y: 5 },
                isOption: true,
            }).popupMenu;
        
            popupMenu.menuClickPopupMenu({
                menuPath: [size]
            });
        }
        
        function setTrackViewTo(view) {
            sf.ui.proTools.selectedTrack.displaySelectorButton.popupMenuSelect({
                isOption: true,
                menuPath: [view]
            });
        }
        
        function main() {
            sf.ui.proTools.appActivateMainWindow();
        
            if (!sf.ui.proTools.selectedTrackCount) {
                determineTopMostEditTrack().trackScrollToView();
            } else {
                sf.ui.proTools.selectedTrack.trackScrollToView();
            }
        
            resizeTracks({ size: 'small' });
            setTrackViewTo('waveform');
        }
        
        main();
        
        1. Awesome! That works perfectly. Thank you :)

          1. EEAB @EAB
              2023-04-27 00:30:14.378Z

              Thank you!

        2. P
          In reply tosbiss:
          Philip weinrobe @Philip_weinrobe
            2022-01-14 17:24:47.941Z

            hey all!
            i'm using this script and it's awesome. from what i can tell what it's actually doing is changing all tracks (regardless of type) to the first view type in their dropdown list (routing folders = overview, aux = volume, audio = waveform).

            this is EXACTLY what i've been looking for.

            however: the script fails if the track selected (or the first track visible at top of screen) is not an audio track. is there a way to modify this so that it first selects an audio track to error-proof the script? otherwise, perfect!

            1. Hmm...I am not having this issue and I just tested it with an aux, a vca, and an instrument track at the top of the screen. I wonder if your issue is caused by something else? But this is probably a question for @raphaelsepulveda who wrote the script! Raphael, I use this literally at least once every five minutes all day long so I thank you for this!

              1. I stand corrected. I just reproduced the issue (though not having to do with the track being at the top of the window). I ran this command while a stereo aux track near the bottom of the screen was selected.

                1. Check out the revised version I just posted. Same functionality as before but eliminates issues like this!

                2. In reply tosbiss:

                  That is awesome to hear!

                3. In reply toPhilip_weinrobe:
                  Raphael Sepulveda @raphaelsepulveda2022-01-15 00:06:19.862Z2024-07-31 18:35:29.433Z

                  Hey @Philip_weinrobe !

                  Glad to hear this script has been helpful for ya!

                  What it does is that it selects "waveform" while holding the option key. The effect that it has on non-audio tracks is of selecting their default track view, which, like you pointed out, happens to be the first item on that popup menu for most tracks.

                  Ah, I see the problem. Here's a revised version that will take care of that issue!

                  Updated July 31st, 2024 to work with latest SF and PT

                  /**
                   * @param {object} arg
                   * @param {AxPtTrackHeader[]} [arg.tracks] - Optional. If provided gets top most from those tracks.
                   */
                  function determineTopMostEditTrack({ tracks } = {}) {
                      function getTopMostTrack(tracks) {
                          return tracks.filter(h => h.frame.y >= editTimeLineTopY)[0];
                      }
                  
                      sf.ui.proTools.mainWindow.invalidate();
                      const editTimeLineTopY = sf.ui.proTools.mainWindow.timelineFocusButton.frame.y;
                      return getTopMostTrack(tracks || sf.ui.proTools.visibleTrackHeaders);
                  };
                  
                  function resizeTracks({ size }) {
                      const f = sf.ui.proTools.selectedTrack.frame;
                      const popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({
                          anchor: "TopLeft",
                          relativePosition: { x: f.w - 10, y: 5 },
                          isOption: true,
                      }).popupMenu;
                  
                      popupMenu.menuClickPopupMenu({
                          menuPath: [size]
                      });
                  }
                  
                  function setTrackViewTo(view) {
                      sf.ui.proTools.selectedTrack.displaySelectorButton.popupMenuSelect({
                          isOption: true,
                          menuPath: [view]
                      });
                  }
                  
                  /** @param {AxPtTrackHeader} track */
                  function isAudioTrack(track) {
                      return track.title.value.endsWith('Audio Track ');
                  }
                  
                  function getAudioTracks() {
                      sf.ui.proTools.mainWindow.invalidate();
                      return sf.ui.proTools.visibleTrackHeaders.filter(isAudioTrack);
                  }
                  
                  function ensureAnAudioTrackIsSelectedAndVisible(audioTracks) {
                      if (!sf.ui.proTools.selectedTrackCount || !isAudioTrack(sf.ui.proTools.selectedTrack)) {
                          determineTopMostEditTrack({ tracks: audioTracks }).trackScrollToView();
                      } else {
                          sf.ui.proTools.selectedTrack.trackScrollToView();
                      }
                  }
                  
                  function main() {
                      sf.ui.proTools.appActivateMainWindow();
                  
                      const audioTracks = getAudioTracks();
                  
                      if (!audioTracks.length) {
                          throw 'An audio track is required.\nPlease make sure there is one present in the session.'
                      }
                  
                      ensureAnAudioTrackIsSelectedAndVisible(audioTracks);
                  
                      resizeTracks({ size: 'small' });
                      setTrackViewTo('waveform');
                  }
                  
                  main();
                  
                  1. VViktor Szabo @Viktor_Szabo
                      2024-07-31 18:25:30.577Z

                      Hi, tried this script what found here, but it is seems not working at pro tool 2024.6, is anything should be updated for this method?

                      thank you

                      1. Hey @Viktor_Szabo, yes, this one required a small tweak to make it work with the latest versions of SF and PT. I've updated the script above. Give it another go!

                        1. VViktor Szabo @Viktor_Szabo
                            2024-07-31 18:50:27.864Z

                            Thank you
                            have a returning line:
                            TypeError: Cannot read property 'title' of null
                            (set all tracks to small height line 37)

                            1. Do you have at least one audio track selected? This script only works on selected tracks.

                              1. VViktor Szabo @Viktor_Szabo
                                  2024-07-31 19:06:58.816Z

                                  Hi Raphael

                                  Yes, have found the bug, if a video track is visible in the session, then this error comes, if I hide the video track, it is working well.
                                  thank you so much

                      2. P
                        In reply tosbiss:
                        Philip weinrobe @Philip_weinrobe
                          2022-01-15 00:34:09.192Z

                          now working PERFECTLY
                          thank you

                          1. S
                            In reply tosbiss:

                            @raphaelsepulveda Thanks for the fix. Working perfectly here too!

                            1. R
                              In reply tosbiss:
                              Robert Schoen @Robert_Schoen
                                2023-05-30 10:28:58.324Z

                                Hi Raphael,
                                works great for me too!
                                Modified question: How to affect only selected tracks regarding track hight, not all?
                                E.g. all tracks remain micro, only the selected ones change to medium?

                                Thanks

                                rob

                                1. Chad Wahlbrink @Chad2023-08-03 15:53:37.840Z

                                  Hey @Robert_Schoen!

                                  You can use this modified script:

                                  // Un-comment Line 2 to set all to micro first
                                  // setAllTracksToSize({ trackSize: "micro".toLowerCase(), forSelection: false });
                                  
                                  setAllTracksToSize({ trackSize: "medium".toLowerCase(), forSelection: true });
                                  
                                  /**
                                   * @param {object} arg
                                   * @param {AxPtTrackHeader[]} [arg.tracks] - Optional. If provided gets top most from those tracks.
                                   */
                                  function determineTopMostEditTrack({ tracks } = {}) {
                                      function getTopMostTrack(tracks) {
                                          return tracks.filter(h => h.frame.y >= editTimeLineTopY)[0];
                                      }
                                  
                                      sf.ui.proTools.mainWindow.invalidate();
                                      const editTimeLineTopY = sf.ui.proTools.mainWindow.timelineFocusButton.frame.y;
                                      return getTopMostTrack(tracks || sf.ui.proTools.visibleTrackHeaders);
                                  };
                                  
                                  function resizeTracks({ size, forSelection }) {
                                      const f = sf.ui.proTools.selectedTrack.frame;
                                      const popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({
                                          relativePosition: { x: f.w - 10, y: 5 },
                                          isOption: true,
                                          isShift: forSelection
                                      }).popupMenu;
                                  
                                      popupMenu.menuClickPopupMenu({
                                          menuPath: [size],
                                  
                                      });
                                  }
                                  
                                  function setTrackViewTo(view) {
                                      sf.ui.proTools.selectedTrack.displaySelectorButton.popupMenuSelect({
                                          isOption: true,
                                          menuPath: [view]
                                      });
                                  }
                                  
                                  /** @param {AxPtTrackHeader} track */
                                  function isAudioTrack(track) {
                                      return track.title.value.endsWith('Audio Track ');
                                  }
                                  
                                  function getAudioTracks() {
                                      sf.ui.proTools.mainWindow.invalidate();
                                      return sf.ui.proTools.visibleTrackHeaders.filter(isAudioTrack);
                                  }
                                  
                                  function ensureAnAudioTrackIsSelectedAndVisible(audioTracks) {
                                      if (!sf.ui.proTools.selectedTrackCount || !isAudioTrack(sf.ui.proTools.selectedTrack)) {
                                          determineTopMostEditTrack({ tracks: audioTracks }).trackScrollToView();
                                      } else {
                                          sf.ui.proTools.selectedTrack.trackScrollToView();
                                      }
                                  }
                                  
                                  function setAllTracksToSize({ trackSize, forSelection }) {
                                      sf.ui.proTools.appActivateMainWindow();
                                  
                                      const audioTracks = getAudioTracks();
                                  
                                      if (!audioTracks.length) {
                                          throw 'An audio track is required.\nPlease make sure there is one present in the session.'
                                      }
                                  
                                      ensureAnAudioTrackIsSelectedAndVisible(audioTracks);
                                  
                                      sf.ui.proTools.invalidate();
                                  
                                      // setTrackViewTo(trackdisplay);
                                  
                                      resizeTracks({ size: trackSize, forSelection: forSelection });
                                  }
                                  
                                2. A
                                  In reply tosbiss:
                                  Alex Gamble @Alex_Gamble
                                    2024-03-24 20:48:13.761Z

                                    @Chad - I've been using a similar script to set all my tracks to small, but I've noticed that it no longer works since updating sound flow to 5.7.6 . Is this happening to anyone else?

                                    Here's my full script below.

                                    
                                    /**
                                     * @param {object} arg
                                     * @param {AxPtTrackHeader[]} [arg.tracks] - Optional. If provided gets top most from those tracks.
                                     */
                                    function determineTopMostEditTrack({ tracks } = {}) {
                                        function getTopMostTrack(tracks) {
                                            return tracks.filter(h => h.frame.y >= editTimeLineTopY)[0];
                                        }
                                    
                                        sf.ui.proTools.mainWindow.invalidate();
                                        const editTimeLineTopY = sf.ui.proTools.mainWindow.timelineFocusButton.frame.y;
                                        return getTopMostTrack(tracks || sf.ui.proTools.visibleTrackHeaders);
                                    };
                                    
                                    function resizeTracks({ size }) {
                                        const f = sf.ui.proTools.selectedTrack.frame;
                                        const popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({
                                            relativePosition: { x: f.w - 10, y: 5 },
                                            isOption: true,
                                        }).popupMenu;
                                    
                                        popupMenu.menuClickPopupMenu({
                                            menuPath: [size]
                                        });
                                    }
                                    
                                    /** @param {AxPtTrackHeader} track */
                                    function isAudioTrack(track) {
                                        return track.title.value.endsWith('Audio Track ');
                                    }
                                    
                                    function getAudioTracks() {
                                        sf.ui.proTools.mainWindow.invalidate();
                                        return sf.ui.proTools.visibleTrackHeaders.filter(isAudioTrack);
                                    }
                                    
                                    function ensureAnAudioTrackIsSelectedAndVisible(audioTracks) {
                                        if (!sf.ui.proTools.selectedTrackCount || !isAudioTrack(sf.ui.proTools.selectedTrack)) {
                                            determineTopMostEditTrack({ tracks: audioTracks }).trackScrollToView();
                                        } else {
                                            sf.ui.proTools.selectedTrack.trackScrollToView();
                                        }
                                    }
                                    
                                    function main() {
                                        sf.ui.proTools.appActivateMainWindow();
                                    
                                        const audioTracks = getAudioTracks();
                                    
                                        if (!audioTracks.length) {
                                            throw 'An audio track is required.\nPlease make sure there is one present in the session.'
                                        }
                                    
                                        ensureAnAudioTrackIsSelectedAndVisible(audioTracks);
                                    
                                        resizeTracks({ size: 'small' });
                                    }
                                    
                                    main();
                                    
                                    1. Chris Shaw @Chris_Shaw2024-03-24 21:16:02.024Z2024-03-24 21:22:09.293Z

                                      SF now defaults to clicking in the mid center of elements instead of top. You just need to set the anchor too "TopLeft" in the resizeTracks function:
                                      see here for a more detailed explanation and options

                                      function resizeTracks({ size }) {
                                          const f = sf.ui.proTools.selectedTrack.frame;
                                          const popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({
                                              anchor:"TopLeft",
                                              relativePosition: { x: f.w - 10, y: 5 },
                                              isOption: true,
                                          }).popupMenu;
                                      
                                          popupMenu.menuClickPopupMenu({
                                              menuPath: [size]
                                          });
                                      }
                                      
                                      1. AAlex Gamble @Alex_Gamble
                                          2024-03-24 21:50:32.168Z

                                          Thanks for the quick response! I'll update my script accordingly