Script that determines the nearest Pro Tools Marker to the parked cursor & copy/pastes the name of the marker to the enabled record track.
I'm looking for a somewhat technical script this time. I do a lot of ADR, and I'm looking for something to give me a bit of a speed boost.
I wanted to see if it would be possible to help me write a script that:
A) determines the nearest marker location based on the timecode position of the parked cursor
B) Selects and opens that marker and copies its text (ie Cassandra001, or pablo003).
C) Pastes the text to the track name of the (only) record enabled track.
Do you think that this is possible for Soundflow?
- DDane Butler @Dane_Butler
samuel henriques @samuel_henriques
Hello Dane,
Sorry I took so long,
try this,function timeCounter() { // get current counter const mainCounter = sf.ui.proTools.getCurrentTimecode().stringValue let originalTimeCounter /// Bars Beats . if (mainCounter.includes("|")) originalTimeCounter = "Bars|Beats" // Min Secs . else if (mainCounter.includes(":") && mainCounter.includes(".")) originalTimeCounter = "Min:Secs" // Time code else if (mainCounter.split(":").length == 4) originalTimeCounter = "Timecode" // Feet+Frames else if (mainCounter.includes("+")) originalTimeCounter = "Feet+Frames" // Samples. else originalTimeCounter = "Samples" return originalTimeCounter } function getNextMarkerName(selection) { let nextMemLoc sf.ui.proTools.memoryLocationsEnsureWindow({ restoreWindowOpenState: true, action: () => { nextMemLoc = sf.proTools.memoryLocationsFetch().collection['List'].slice().find(m => m.mainCounterValue >= selection.selectionStart ); } }); return nextMemLoc ? nextMemLoc["name"] : undefined }; function getRecordEnabledTracks() { const visibleTracks = sf.ui.proTools.visibleTrackHeaders const recTrack = visibleTracks.find(tr => { const recButton = tr.buttons.whoseTitle.is("Track Record Enable").first return recButton.exists && recButton.value.invalidate().value.includes("on state") }); return recTrack } function getSessionInfo() { try { // Get user info this.originalTimeCounter = timeCounter(); this.originalSelectedTracks = sf.ui.proTools.selectedTrackHeaders; // Get info this.recordEnabledTrack = getRecordEnabledTracks(); //Set samples, setting here will prevent from changing more than once. sf.ui.proTools.mainCounterSetValue({ targetValue: "Samples" }); this.currentSelection = sf.ui.proTools.selectionGetInSamples(); this.nextMarkerName = getNextMarkerName(this.currentSelection); //Functions and set user original this.renameRecTrack = () => { this.recordEnabledTrack.trackSelect(); this.recordEnabledTrack.trackScrollToView(); this.recordEnabledTrack.trackBulkRename({ newName: this.nextMarkerName }); sf.ui.proTools.invalidate(); }; this.setUserOriginals = () => { const originalSelected = this.originalSelectedTracks; if (originalSelected.length > 0) { // Selected Track originalSelected[0].trackSelect(); originalSelected[0].trackScrollToView(); sf.ui.proTools.trackSelectByName({ names: originalSelected.map(th => th.normalizedTrackName) }); }; //user counter sf.ui.proTools.mainCounterSetValue({ targetValue: this.originalTimeCounter }); }; } catch (err) { throw err }; }; function main() { sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.invalidate(); const session = new getSessionInfo(); try { if (!session.recordEnabledTrack) { alert("No record track found."); throw 0 }; if (!session.nextMarkerName) { alert("No More Memory Locations."); throw 0 }; session.renameRecTrack(); } catch (err) { throw err } finally { session.setUserOriginals(); }; }; main();
- DDane Butler @Dane_Butler
Hey!!!!
Thanks so much for getting back to me! I’ll give this a go here in a few minutes!! 😬😬😬😬
- In reply tosamuel_henriques⬆:DDane Butler @Dane_Butler
Hey!
So first of all great work! This will help me so much. It does work, but it also throws this error code...
09.12.2022 10:24:08.97 [Backend]: !! Command Error: Get Timecode to Record [user:cl5r700c40003c710l3rhtp28:clbgpq2mc000eue10f0gxcle1]:
Selected track header and track list item does not match. List Name: ''. Header Name: 'Dad002' (Get Timecode to Record: Line 80)I notice I have to park the cursor before the marker in order to pull the timecode marker name, but that's easy enough to work with! Thank you so much.
samuel henriques @samuel_henriques
I thought I had fixed this error, I'll check again in a bit. I think it only happens if you don't have any track selected before running the script.
I notice I have to park the cursor before the marker in order to pull the timecode marker name, but that's easy enough to work with! Thank you so much.
This is what I understood from you request "A) determines the nearest marker location based on the timecode position of the parked cursor"
Do you want nearest before or after? Or something else?
- DDane Butler @Dane_Butler
Yeah I had a track selected! I always have the "link edit & track selection" button lit up. I think what you did was better than what I was thinking initially. Initially had the idea of the script making said determination based off of proximity with both before and after being taken into consideration, but just before is better because I think it will lead to more predictable performance so no need to change anything there! Just curious about the error code but like I said that's no big deal because it still works. Just a lot of pop up notifications
samuel henriques @samuel_henriques
ok cool.
That error is stupid, I'll figure out what I did wrong. Probably has to do with the method I used to create the functions, it's something new to me that I was playing with.samuel henriques @samuel_henriques
Having trouble reproducing the error.
Updated a new version and tweaked some bits, if you still see the erros make a video capture of the script failing so I can see if i missed something.samuel henriques @samuel_henriques
New Update just now.
samuel henriques @samuel_henriques
Just Updated, slightly faster version.
- DDane Butler @Dane_Butler
Copy that! I’ll give it a go & take a screenshot tomorrow!
- In reply tosamuel_henriques⬆:DDane Butler @Dane_Butler
You're the man Sam! This works flawlessly.