No internet connection
  1. Home
  2. Support

A way to 'show only tracks in group' when using folders with nested folders

By Will Cohen @Will_Cohen
    2020-09-29 16:27:48.725Z

    Hey!

    I'm trying to find a way to view only certain groups of tracks - I know the memory allocation way but it messes up when adding tracks and throws all the views out... so I'm back to trying to get it to work with groups...

    My main PT template has e.g. an MX folder, and nested within, an MX A and an MX A folder.

    If I use https://forum.soundflow.org/-759/show-and-hide-groups, to show just 'MX A' within MX, it hides all other tracks not within MX but still shows MXb as well as the main MX folder and any other content in MX (reverb returns etc...)

    If just right clicking manually on a group in the list in PT and selecting 'Show Only Tracks in Group' it works as expected... is there a way to replicate that exactly?

    • 12 replies
    1. W
      Will Cohen @Will_Cohen
        2020-09-29 17:15:27.757Z

        Hmm - maybe the easiest way would be make a script that selects a folder by predefined name, say 'DX returns' and all tracks within it? Then the menu command 'show only selected tracks' would work... then it would avoid messing around with groups.

        Screengrab of what I mean attached...

        1. This "little" beauty should do it-ish:

          const folderName = "Folder 1";
          
          /**
           * @param {AxPtTrackHeader} track
           */
          function getTrackDepth(track) {
              return Math.floor((track.titleButton.frame.x - track.frame.x) / 15);
          }
          
          function getTrackFolderStructure() {
              var root = { children: [] };
              var stack = [];
              stack[0] = root;
              var flatList = sf.ui.proTools.visibleTrackHeaders.map(t => ({ track: t, depth: getTrackDepth(t) }));
              for (var i = 0; i < flatList.length; i++) {
                  var flatItem = flatList[i];
                  var node = {
                      name: flatItem.track.normalizedTrackName,
                      type: flatItem.track.title.value.match(/ - (.*)$/)[1].trim().replace(/track$/i, '').trim().toLowerCase(),
                      track: flatItem.track,
                      children: []
                  };
                  stack[flatItem.depth] = node;
                  stack[flatItem.depth - 1].children.push(node);
              }
              return root;
          }
          
          function findNearestParentFolder(root, trackName) {
              var folderStack = [];
              function walk(node) {
                  var isFolder = node.type && node.type.indexOf('folder') >= 0;
                  if (isFolder) {
                      folderStack.push(node);
                  }
                  if (node.name === trackName) {
                      return folderStack.slice(-1)[0];
                  }
                  for (var i = 0; i < node.children.length; i++) {
                      var res = walk(node.children[i]);
                      if (res) return res;
                  }
                  if (isFolder) {
                      folderStack.pop();
                  }
              }
              return walk(root);
          }
          
          /**
           * @param {AxPtTrackHeader} folderTrack
           * @param {boolean} includeFolder
           * @return {AxPtTrackHeader[]}
           */
          function getTracksInFolder(folderTrack, includeFolder) {
              var root = getTrackFolderStructure();
          
              var nearestFolder = findNearestParentFolder(root, folderTrack.normalizedTrackName);
              if (!nearestFolder)
                  return [];
          
              let subTracks = nearestFolder.children.map(i => i.track);
              return includeFolder ? [folderTrack, ...subTracks] : subTracks;
          }
          
          function selectTracksInFolder(folderTrack, includeFolder) {
              sf.ui.proTools.trackSelectByName({
                  names: getTracksInFolder(folderTrack, includeFolder).map(t => t.normalizedTrackName),
              });
          }
          
          function getInputPathOfSelectedTrack() {
              sf.ui.proTools.appActivateMainWindow();
              var path = sf.ui.proTools.selectedTrack.inputPathButton.popupMenuFetchAllItems().menuItems.filter(mi => mi.element.isMenuChecked)[0].names;
              sf.ui.proTools.appActivateMainWindow();
              return path;
          }
          
          function main() {
              sf.ui.proTools.invalidate();
          
              //Get folder track
              let track = sf.ui.proTools.trackGetByName({ name: folderName }).track;
          
              //Make sure current folder is open
              track.folderTrackSetOpen({
                  targetValue: "Enable",
              });
          
              //Select all audio tracks in folder
              selectTracksInFolder(track, true);
          
              //Only show these
              sf.ui.proTools.trackListMenu({
                  menuItemName: 'Show Only Selected Tracks',
              });
          }
          
          main();
          
          1. I'll include this soon in a template collection I'm building based off of advanced PT workflows we're starting to support :)

            1. Then it'll be configurable like this:

        2. W
          In reply toWill_Cohen:
          Will Cohen @Will_Cohen
            2020-09-29 19:50:33.644Z

            Nice, thanks C, will give it a crack tomorrow... cheers man!

            1. W
              In reply toWill_Cohen:
              Will Cohen @Will_Cohen
                2020-09-30 09:19:28.142Z

                This is ace thanks Christian.

                Would it speed up when built into a command? Definitely already better than alternatives for me anyway, thanks so much!

                1. W
                  In reply toWill_Cohen:
                  Will Cohen @Will_Cohen
                    2020-09-30 09:28:42.936Z

                    Actually seems to be a problem with this working if tracks are minimal height... also doesn't work if folder is within a folder that is closed.

                    1. W
                      In reply toWill_Cohen:
                      Will Cohen @Will_Cohen
                        2020-09-30 09:36:26.072Z

                        Sorry for the stream of consciousness... I guess it would need a 'select track and expand folder' to allow the nested folders to be visible in track list. That much is within my abilities to add in (sorry for incompetence).

                        1. W
                          In reply toWill_Cohen:
                          Will Cohen @Will_Cohen
                            2020-10-04 15:30:09.132Z

                            Unfortunately can't get this to work when folders are nested. I thought maybe this would work:

                            sf.ui.proTools.trackSelectByName({
                            names: ["MIX"],
                            });

                            sf.ui.proTools.selectedTrack.folderTrackSetOpen({
                            targetValue: "Enable",
                            });

                            sf.soundflow.runCommand({
                            commandId: 'user:ckaau9ser00065r10qby1pekn:ckftn5msy0009vz106ga6t588',
                            props: {
                            folder: sf.ui.proTools.trackGetByName({ name: "INSTR", makeVisible: true }).track,
                            action: "ShowOnly",
                            includeFolder: true,
                            }
                            });

                            1. W
                              In reply toWill_Cohen:
                              Will Cohen @Will_Cohen
                                2020-10-04 15:31:31.924Z

                                This is where INSTR folder is nested within MIX folder and you would want to just view the INSTR folder when the mix folder is closed.

                                1. W
                                  In reply toWill_Cohen:
                                  Will Cohen @Will_Cohen
                                    2020-10-07 08:57:15.751Z

                                    Hey guys, any ideas? Shelving this for now... uff!

                                    1. J
                                      In reply toWill_Cohen:
                                      Jasper van Dijk @Jasper_van_Dijk
                                        2023-06-15 20:22:01.659Z

                                        Any solution to this? Would be an absolute game changer. Currently getting it to work, except if there's folders within folders.