A way to 'show only tracks in group' when using folders with nested folders
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?
- WWill Cohen @Will_Cohen
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...
Christian Scheuer @chrscheuer2020-09-29 19:23:16.486Z
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();
Christian Scheuer @chrscheuer2020-09-29 19:25:05.271Z
I'll include this soon in a template collection I'm building based off of advanced PT workflows we're starting to support :)
Christian Scheuer @chrscheuer2020-09-29 19:26:31.496Z
Then it'll be configurable like this:
- WIn reply toWill_Cohen⬆:Will Cohen @Will_Cohen
Nice, thanks C, will give it a crack tomorrow... cheers man!
- WIn reply toWill_Cohen⬆:Will Cohen @Will_Cohen
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!
- WIn reply toWill_Cohen⬆:Will Cohen @Will_Cohen
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.
- WIn reply toWill_Cohen⬆:Will Cohen @Will_Cohen
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).
- WIn reply toWill_Cohen⬆:Will Cohen @Will_Cohen
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,
}
}); - WIn reply toWill_Cohen⬆:Will Cohen @Will_Cohen
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.
- WIn reply toWill_Cohen⬆:Will Cohen @Will_Cohen
Hey guys, any ideas? Shelving this for now... uff!
- JIn reply toWill_Cohen⬆:Jasper van Dijk @Jasper_van_Dijk
Any solution to this? Would be an absolute game changer. Currently getting it to work, except if there's folders within folders.