No internet connection
  1. Home
  2. Support

Delete muted clips with fades

By Christopher Barnett @Christopher_Barnett
    2020-06-30 03:41:05.074Z

    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 ?

    Solved in post #2, click to view
    • 7 replies
    1. S

      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=0

      I 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
      
      Reply3 LikesSolution
      1. Kitch Membery @Kitch2020-06-30 05:04:51.052Z

        Nice work!

        1. 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...
              }
          });
          
        2. J
          Jeremy Bowker @Jeremy_Bowker
            2021-01-12 17:19:46.843Z

            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. =)

            1. J
              Justin Randell @Justin_Randell
                2021-08-04 09:48:29.133Z

                Super useful, makes you wonder why Avid haven't implemented this!

                1. T
                  Tristan Hoogland @Tristan
                    2021-12-22 01:09:11.959Z

                    Amazing! Can't believe I missed this one, not only a time saver, but also arguably more reliable than doing it manually. Thanks :)

                    1. F
                      Felipe Gutierrez @Felipe_Gutierrez
                        2022-10-05 17:16:31.725Z

                        Absolutely amazing. Thanks so much!