Soundflow challenge: I am trying to make an action that clears all the muted clips in a track over a selection in protools. It leaves all the others intact but only clears the muted ones. I cannot figure it out, also Imagine there are hundred of muted clips in a session that I want to clear. If this is possible that would be amazing, but I cannot figure it out. Is it possible ?
- SSaethor Kristjansson @Saethor_Kristjansson
I was just replying to your FB post when it got deleted!
I did a similar script in AppleScript a couple of years ago, here is a quick SF version of that. It changes the Main Counter to samples first (easy to compare values, so the script can know when its moved outside of the original selection), and uses the control+tab keystroke to go between clips, checking first if the clip selected is within the original selected range, and then removes the clip if it's muted.
Video of it in action:
https://www.dropbox.com/s/78osnhlo6t6jlpf/Screen Recording 2020-06-30 at 03.48.14.mov?dl=0I just threw this together in the last hour and there are probably many ways this can be improved. For example if there is a muted clip at the exact point the selection starts (if you just use cmd+a to select all clips on the track) the script will miss the first one. Also, since this is using keystrokes and goes pretty fast, you might want to add some safeguards, like duplicating the playlists before the script starts, or adding a pause between tracks so you can cancel/abort, just in case the script fails or does something unexpected. ESPECIALLY if you're doing this in bigger and more complex sessions. This script is working perfectly for me right now in this session but there are always unforeseen problems that come up when you try it out in real world scenarios.
There might also be some SF functions I'm not aware of that could make this simpler (like getting the current Main Counter type), I'm pretty new to SF and JavaScript!
Here's the script:
sf.ui.proTools.appActivateMainWindow() function getPreviousMainCounter() { // Get Main Counter so we can change it back when we're done let menuItems = sf.ui.proTools.getMenuItem('View', 'Main Counter').children.first.children.allItems for(let i = 0; i < menuItems.length; i++) { let currentMenuItem = menuItems[i] if(currentMenuItem.isMenuChecked) { return currentMenuItem.title.value } } } function getEditSelectionStart() { return Number(sf.ui.proTools.selectionGet().selectionStart) } function getEditSelectionEnd() { return Number(sf.ui.proTools.selectionGet().selectionEnd) } function clearIfMuted() { if(sf.ui.proTools.getMenuItem('Edit', 'Unmute Clips').exists) { sf.ui.proTools.menuClick({menuPath: ['Edit', 'Clear']}) // If the muted clip had a fade-in that doesn't get deleted so we go back a step and check if we find a muted clip where the fade-in was sf.keyboard.press({keys: "control+option+tab"}) clearIfMuted() } } var oldMainCounter = getPreviousMainCounter() if (oldMainCounter != "Samples") { sf.ui.proTools.mainCounterSetValue({targetValue: "Samples"}) } var startPosition = getEditSelectionStart() var endPosition = getEditSelectionEnd() var selectedTracks = sf.ui.proTools.selectedTrackNames for(let i = 0; i < selectedTracks.length; i++) { let currentTrack = selectedTracks[i] let currentPosition = 0 let previousPosition = 0 sf.ui.proTools.selectionSetInSamples({selectionStart: startPosition, selectionEnd: endPosition}) sf.ui.proTools.trackSelectByName({names: [currentTrack], deselectOthers: true}) let doneWithTrack = false while(!doneWithTrack) { previousPosition = getEditSelectionStart() sf.keyboard.press({keys: "control+tab"}) currentPosition = getEditSelectionStart() if (getEditSelectionEnd() > endPosition || previousPosition === currentPosition) { doneWithTrack = true } else { clearIfMuted() } } } if(oldMainCounter != "Samples") { sf.ui.proTools.mainCounterSetValue({targetValue: oldMainCounter })} // Reset the main counter
Kitch Membery @Kitch2020-06-30 05:04:51.052Z
Nice work!
- In reply toSaethor_Kristjansson⬆:
Kitch Membery @Kitch2020-06-30 05:20:48.589Z
Here is how to swap the main counter to samples for the duration of the script. :-)
sf.ui.proTools.mainCounterDoWithValue({ targetValue: 'Samples', action: () => { //Do some stuff here... } });
- JIn reply toChristopher_Barnett⬆:Jeremy Bowker @Jeremy_Bowker
This is amazing! I'm running into one (very small) issue: If there is a muted clip, before the selection in the time line, that clip is also removed from the time line. Is anyone else running into this. Anyway, once again, this is very exciting/impressive. =)
- JIn reply toChristopher_Barnett⬆:Justin Randell @Justin_Randell
Super useful, makes you wonder why Avid haven't implemented this!
- TIn reply toChristopher_Barnett⬆:Tristan Hoogland @Tristan
Amazing! Can't believe I missed this one, not only a time saver, but also arguably more reliable than doing it manually. Thanks :)
- FIn reply toChristopher_Barnett⬆:Felipe Gutierrez @Felipe_Gutierrez
Absolutely amazing. Thanks so much!