Desired Workflow
I select only Stereo Tracks in already selected Tracks.
Question
Now, this script will select only the stereo tracks from all the tracks in the session.
I would like to modify this script to select only the stereo of the currently selected track.
Command Info
ID: user:ckn2gzwxh0000e71043ve6uq8:cknihgx63000sr0103hjyr7u1
Name: test
Source
function isAudioTrack(trackName) {
var track = sf.ui.proTools.trackGetByName({ name: trackName }).track;
if (!track) return;
return track.title.value.indexOf('Audio Track') >= 0;
}
function getTrackWidth(trackName) {
var track = sf.ui.proTools.trackGetByName({ name: trackName }).track;
var width = track.groups.whoseTitle.is('Audio IO').first.sliders.whoseTitle.contains('Pan').count;
return width;
}
function selectAllAudioTracksOfWidth(width) {
var names = sf.ui.proTools.trackNames.filter(isAudioTrack).filter(t => getTrackWidth(t) === width);
if (names.length === 0) return;
sf.ui.proTools.trackGetByName({ name: names[0] }).track.trackScrollToView();
sf.ui.proTools.trackSelectByName({
names: names,
deselectOthers: true
});
}
//To select all stereo audio tracks
selectAllAudioTracksOfWidth(2);
Links
User UID: 2rFAsTbdHvMB0V3hq0Qqhg8wpZy2
Feedback Key: sffeedback:2rFAsTbdHvMB0V3hq0Qqhg8wpZy2:-MYJCL-4ceYP4WqRzbwo
- Christian Scheuer @chrscheuer2021-04-15 10:57:20.688Z
Try this:
function isAudioTrack(trackName) { var track = sf.ui.proTools.trackGetByName({ name: trackName }).track; if (!track) return; return track.title.value.indexOf('Audio Track') >= 0; } function getTrackWidth(trackName) { var track = sf.ui.proTools.trackGetByName({ name: trackName }).track; var width = track.groups.whoseTitle.is('Audio IO').first.sliders.whoseTitle.contains('Pan').count; return width; } function selectAllSelectedAudioTracksOfWidth(width) { var names = sf.ui.proTools.selectedTrackNames.filter(isAudioTrack).filter(t => getTrackWidth(t) === width); if (names.length === 0) return; sf.ui.proTools.trackGetByName({ name: names[0] }).track.trackScrollToView(); sf.ui.proTools.trackSelectByName({ names: names, deselectOthers: true }); } //To select all stereo audio tracks selectAllSelectedAudioTracksOfWidth(2);
Yujiro Yonetsu @Yujiro_Yonetsu
It's perfect!
Thank you!
- CIn reply toYujiro_Yonetsu⬆:Charles Elmi @Charles_Elmi
Just a side note:
When a track is set to 'no output' the panners are gone and getTrackWidth in this case will return 0.
My solution/fallback for this has been to detect if returned value is zero and if so, check if menuPath:
'Track > Split into Mono' is available for the specific track.
If yes assume 'stereo'; if no assume 'mono'. Has been working so far.
This works for following track types:
Audio Tracks
Aux Tracks
Master Tracks
Instrument Tracks
However it does not work for Routing Folder Tracks.
So one needs to detect if requested track falls into the category of 'working track types' and if so apply the 'fallback'.
Hope this helps someone, and if there's a better solution I would love to know!! :)
//Charles