UI from a selected track
Hello! I'm thinking of a macro that enables varispeed mode on a selected track and sets it to ticks mode. What could be the appropriate command to use to click the elastic audio menu and the sample / ticks menu on a selected track and choose the parameter I want? I'm not sure how to work with the UI of the selected tracks (the way it works regardless of the selected track) because when I pick an element it get associated with a particular track name.
Thanks!!
- samuel henriques @samuel_henriques
hello @Juan_B_Caballero,
I got carried away and made this, hope it works for you.
function getCurrentTrackHeight(h) { let originalTrackHeight; let isTrackTooSmall = (h <= 43) ? true : false; switch (true) { case (h <= 16): originalTrackHeight = 'micro'; break; case (h === 23): originalTrackHeight = 'mini'; break; case (h === 43): originalTrackHeight = 'small'; break; case (h === 97): originalTrackHeight = 'medium'; break; case (h === 192): originalTrackHeight = 'large'; break; case (h === 300): originalTrackHeight = 'jumbo'; break; case (h > 300): originalTrackHeight = 'extreme'; break; } return { originalTrackHeight, isTrackTooSmall } } function setTrackSize(size) { var f = sf.ui.proTools.selectedTrack.frame; var popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({ relativePosition: { x: f.w - 10, y: 5 }, isOption: true, isShift: true, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } function main(timebase, elasticAudioPlugin) { const selectedTrackHeight = sf.ui.proTools.selectedTrack.frame.h; let { originalTrackHeight, isTrackTooSmall } = getCurrentTrackHeight(selectedTrackHeight) if (isTrackTooSmall) { setTrackSize("medium") } // get current timebase let timebaseCurrent = sf.ui.proTools.selectedTrack.popupButtons.whoseValue.is("").allItems[1].invalidate().title.value.split(" (").slice(1)[0].slice(0, -1) timebaseCurrent = timebaseCurrent.charAt(0).toUpperCase() + timebaseCurrent.slice(1) // get current elastic audio plugin const elasticAudioCurrent = sf.ui.proTools.selectedTrack.popupButtons.allItems[4].invalidate().value.value; // set timebase if (timebaseCurrent != timebase) { sf.ui.proTools.selectedTrack.popupButtons.allItems[3].popupMenuSelect({ menuPath: [timebase] }); } if (elasticAudioCurrent !== elasticAudioPlugin) { sf.ui.proTools.selectedTrack.popupButtons.allItems[4].popupMenuSelect({ menuPath: [elasticAudioPlugin] }); } } main("Ticks", "Varispeed")
Let me know it it works for you.
For your other question, what you do is use the click ui just as you tried,
change the last bit to the number of ui:
then copy the as Javascript:
and paste on the script editor.
sf.ui.proTools.mainWindow.groups.whoseTitle.is("18 Audio 1.dup1 - Audio Track ").first.popupButtons.allItems[4].elementClick();
replace the items that identify the track name with
selectedTrack
like so:sf.ui.proTools.selectedTrack.popupButtons.allItems[4].elementClick();
In the case you want to choose from popup, use the "Open & Select Item in Popup Menu", and do the same steps.
hope this makes sense.
- JJuan B Caballero @Juan_B_Caballero
The script is amazing!! Thank you!
I got what you told me about the UI-selected track, I'll try it as soon as I can!samuel henriques @samuel_henriques
Realy happy its working for you,
made a more complete one, it will set track hight as it was before(proximate size) and work even if an elastic audio plugin is already open. And will do it for all selected tracks.
here you go:
function getCurrentTrackHeight(h) { let originalTrackHeight; let isTrackTooSmall = (h <= 43) ? true : false; switch (true) { case (h <= 16): originalTrackHeight = 'micro'; break; case (h === 23): originalTrackHeight = 'mini'; break; case (h >= 43 && h <= 61): originalTrackHeight = 'small'; break; case (h >= 79 && h <= 116): originalTrackHeight = 'medium'; break; case (h >= 135 && h <= 235): originalTrackHeight = 'large'; break; case (h >= 257 && h <= 420): originalTrackHeight = 'jumbo'; break; case (h > 440): originalTrackHeight = 'extreme'; break; } return { originalTrackHeight, isTrackTooSmall } } function setTrackSize(size) { var f = sf.ui.proTools.selectedTrack.frame; var popupMenu = sf.ui.proTools.selectedTrack.popupMenuOpenFromElement({ relativePosition: { x: f.w - 10, y: 5 }, isOption: true, isShift: true, }).popupMenu; popupMenu.menuClickPopupMenu({ menuPath: [size] }); } function setElasticAudioPluginFromPopup(elasticAudioPlugin) { const elasticAudioCurrent = sf.ui.proTools.focusedWindow.popupButtons.allItems[2].invalidate().value.value; if (elasticAudioCurrent != elasticAudioPlugin) { sf.ui.proTools.focusedWindow.popupButtons.allItems[2].popupMenuSelect({ menuPath: [elasticAudioPlugin], }); } } function main(timebase, elasticAudioPlugin) { const selectedTrackHeight = sf.ui.proTools.selectedTrack.frame.h; let { originalTrackHeight, isTrackTooSmall } = getCurrentTrackHeight(selectedTrackHeight) if (isTrackTooSmall) { setTrackSize("medium") } // get current timebase let timebaseCurrent = sf.ui.proTools.selectedTrack.popupButtons.whoseValue.is("").allItems[1].invalidate().title.value.split(" (").slice(1)[0].slice(0, -1) timebaseCurrent = timebaseCurrent.charAt(0).toUpperCase() + timebaseCurrent.slice(1) // get current elastic audio plugin const elasticAudioCurrent = sf.ui.proTools.selectedTrack.popupButtons.allItems[4].invalidate().value.value; // set timebase if (timebaseCurrent != timebase) { sf.ui.proTools.selectedTrack.popupButtons.allItems[3].popupMenuSelect({ menuPath: [timebase] }); } // set elastic audio plugin if (elasticAudioCurrent != elasticAudioPlugin) { try { sf.ui.proTools.selectedTrack.popupButtons.allItems[4].popupMenuSelect({ menuPath: [elasticAudioPlugin], timeout: 100 }); } catch (e) { setElasticAudioPluginFromPopup(elasticAudioPlugin) } } // get current track hight as it might have changed, if its between PT sizes, aproximate will be set const currentTrackHight = sf.ui.proTools.selectedTrack.frame.h; if (currentTrackHight != selectedTrackHeight) setTrackSize(originalTrackHeight) } //Get selected tracks const originalTracks = sf.ui.proTools.selectedTrackNames; //Do for each track. sf.ui.proTools.selectedTracks.trackHeaders.slice().map(track => { //Select track track.trackSelect(); //Scroll track into View track.trackScrollToView(); /// set desired settings main("Ticks", "Varispeed") }); //Restore previously selected tracks sf.ui.proTools.trackSelectByName({ names: originalTracks });
- JJuan B Caballero @Juan_B_Caballero
Even better!!! Rock on!!
- In reply tosamuel_henriques⬆:JJuan B Caballero @Juan_B_Caballero
Works Niceeeee!!