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) { };
- Raphael Sepulveda @raphaelsepulveda2021-11-13 04:29:12.854Z
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'] });
- SSteve Bissinger @sbiss2021-11-13 04:37:07.072Z
Hi Raphael! Hmm...it's only selecting one track to set to waveform view, not all tracks.
Raphael Sepulveda @raphaelsepulveda2021-11-13 05:06:36.851Z
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();
- SSteve Bissinger @sbiss2021-11-13 06:23:40.800Z
Awesome! That works perfectly. Thank you :)
- PIn reply tosbiss⬆:Philip weinrobe @Philip_weinrobe
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!
- SSteve Bissinger @sbiss2022-01-14 17:43:24.219Z
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!
- SSteve Bissinger @sbiss2022-01-14 20:37:25.538Z
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.
Raphael Sepulveda @raphaelsepulveda2022-01-15 00:08:04.231Z
Check out the revised version I just posted. Same functionality as before but eliminates issues like this!
- In reply tosbiss⬆:
Raphael Sepulveda @raphaelsepulveda2022-01-15 00:07:08.170Z
That is awesome to hear!
- 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();
- VViktor Szabo @Viktor_Szabo
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
Raphael Sepulveda @raphaelsepulveda2024-07-31 18:37:10.880Z
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!
- VViktor Szabo @Viktor_Szabo
Thank you
have a returning line:
TypeError: Cannot read property 'title' of null
(set all tracks to small height line 37)Raphael Sepulveda @raphaelsepulveda2024-07-31 18:54:34.833Z
Do you have at least one audio track selected? This script only works on selected tracks.
- VViktor Szabo @Viktor_Szabo
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
- PIn reply tosbiss⬆:Philip weinrobe @Philip_weinrobe
now working PERFECTLY
thank you - SIn reply tosbiss⬆:Steve Bissinger @sbiss2022-01-15 01:35:34.684Z
@raphaelsepulveda Thanks for the fix. Working perfectly here too!
- RIn reply tosbiss⬆:Robert Schoen @Robert_Schoen
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
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 }); }
- AIn reply tosbiss⬆:Alex Gamble @Alex_Gamble
@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();
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 theresizeTracks
function:
see here for a more detailed explanation and optionsfunction 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] }); }
- AAlex Gamble @Alex_Gamble
Thanks for the quick response! I'll update my script accordingly