No internet connection
  1. Home
  2. How to

Clear Muted Clips From Selected Track

By @anon6770933309
    2018-07-16 19:45:26.667Z

    This is basically a translation of my AppleScript I wrote years ago, incl. some fixes. Thx a ton to @chrscheuer
    Note: It works fine but doesn't catch muted clips with sync points, thus it will be improved very soon!

    // This script clears all muted clips from the currently selected track
    // It includes code from Oliver Momm, Christian Scheuer
    // Note: This version doesn't catch clips with sync points, it will be improved though
    
    // Check if track is selected
    if (!sf.ui.proTools.getMenuItem('Track', 'Make Inactive').isEnabled) {
        return;
    }
    else {
        // "Return" key to go to start of session
        sf.keyboard.press({
            keys: 'return'
        });
    
        // Select first clip
        sf.keyboard.press({
            keys: 'shift+tab'
        });
    
        // Repeat while audio is still selected
        while (sf.ui.proTools.getMenuItem('Clip', 'Group').isEnabled) {
    
            var clipIsMuted = sf.ui.proTools.hasMenuItem('Edit', 'Unmute Clips');
            var clipIsUnmuted = sf.ui.proTools.hasMenuItem('Edit', 'Mute Clips');
            var noClips = sf.ui.proTools.hasMenuItem('Edit', 'Mute');
    
            if (clipIsMuted) {
                // Clip is muted
                // Delete clip
                sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Clear'] });
            }
            else if (clipIsUnmuted || noClips) {
                // Skip clip
                sf.keyboard.press({
                    keys: 'tab'
                });
            }
    
            // Select next clip
            sf.keyboard.press({
                keys: 'shift+tab'
            });
        }
    
        log('Clear Muted Clips', 'All muted clips cleared from this track');
    }
    
    // Go to start of session
    sf.keyboard.press({
        keys: 'return'
    });
    
    • 18 replies

    There are 18 replies. Estimated reading time: 14 minutes

    1. S
      Sean @SeanH
        2018-07-17 06:31:58.667Z

        this is awesome and thank you for sharing!

        would it be possible to tweak this so you could do it "within current selection" rather then on the whole session? just curious.

        1. ?@anon6770933309
            2018-07-17 13:38:25.330Z

            I wouldn't have a quick solution for this particular script version but like I mentioned, this script will be improved anyway as Christian added some cool new functions to SF.
            Unfortunately the new script still needs some debugging. When this is done I can think of alternative versions, e.g. for current selection, or all tracks in a session etc. 😉

          • D
            Davide Favargiotti @dieffe
              2018-07-17 12:16:48.633Z

              Nice.
              Thank you for sharing. I'm thinking to have a another script that move the muted clips to a specific track. I'll give it a try now and will post it here

              1. D
                Davide Favargiotti @dieffe
                  2018-07-17 12:21:19.186Z

                  The only "issue" I found so far is that some muted clips with in and out fades are deleted but a tiny clip is left in place of the fade in

                  1. ?@anon6770933309
                      2018-07-17 12:48:25.542Z

                      There was an extra step in my original AppleScript but I couldn't remember what it was good for and decided to get rid of it.
                      Can you send me a short sample session, with silence as audio and some fades?

                      1. ?@anon6770933309
                          2018-07-17 13:32:38.645Z

                          I think I fixed it. I want to try it on one of your sessions though.

                          1. DDavide Favargiotti @dieffe
                              2018-07-17 14:17:12.325Z

                              how can I send it? is FB ok for you?

                              1. ?@anon6770933309
                                  2018-07-17 14:36:52.233Z

                                  Sure.

                                  1. In reply todieffe⬆:
                                    ?@anon6770933309
                                      2018-07-17 20:32:57.187Z

                                      I haven't received a session from you. So, I take it you fixed it yourself. 😉

                                      1. ?@anon6770933309
                                          2018-07-18 06:54:05.674Z

                                          Looks like it took half a day to show up on FB. I left a msg over there.

                                  2. In reply todieffe⬆:
                                    ?@anon6770933309
                                      2018-07-18 13:54:57.503Z

                                      Thx a lot for catching this, Davide.
                                      Like I suspected, it was that missing step that I did not translate from my AppleScript which takes care of it.
                                      This should work now and catch fade ins.:

                                      // This script clears all muted clips from the currently selected track
                                      // It includes code from Oliver Momm, Christian Scheuer
                                      // Note: This version doesn't catch clips with sync points, it will be improved though
                                      
                                      // Check if track is selected
                                      if (!sf.ui.proTools.getMenuItem('Track', 'Make Inactive').isEnabled) {
                                          return;
                                      }
                                      else {
                                          // "Return" key to go to start of session
                                          sf.keyboard.press({
                                              keys: 'return'
                                          });
                                      
                                          // Select first clip
                                          sf.keyboard.press({
                                              keys: 'shift+tab'
                                          });
                                      
                                          // Repeat while audio is still selected
                                          while (sf.ui.proTools.getMenuItem('Clip', 'Group').isEnabled) {
                                      
                                              var clipIsMuted = sf.ui.proTools.hasMenuItem('Edit', 'Unmute Clips');
                                              var clipIsUnmuted = sf.ui.proTools.hasMenuItem('Edit', 'Mute Clips');
                                              var noClips = sf.ui.proTools.hasMenuItem('Edit', 'Mute');
                                      
                                              if (clipIsMuted) {
                                                  // Clip is muted
                                                  // Delete clip
                                                  sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Clear'] });
                                      
                                                  // "Option+Shift+Tab" keys to extend selection to previous Clip-boundary
                                                  sf.keyboard.press({
                                                      keys: 'alt+shift+tab'
                                                  });
                                              }
                                              else if (clipIsUnmuted || noClips) {
                                                  // Skip clip
                                                  sf.keyboard.press({
                                                      keys: 'tab'
                                                  });
                                              }
                                      
                                              // Select next clip
                                              sf.keyboard.press({
                                                  keys: 'shift+tab'
                                              });
                                          }
                                      
                                          log('Clear Muted Clips', 'All muted clips cleared from this track');
                                      }
                                      
                                      // Go to start of session
                                      sf.keyboard.press({
                                          keys: 'return'
                                      });
                                      
                                      
                                      1. DDavide Favargiotti @dieffe
                                          2018-07-18 22:15:18.768Z

                                          Thanks Oli, tried the new version and it works as expected! Awesome!

                                          1. Jjames hynes @james_hynes
                                              2020-03-28 15:53:48.217Z2020-03-28 16:08:10.998Z

                                              .

                                            • Nnick krill @nick_krill
                                                2023-03-03 19:10:10.349Z

                                                Wow this is super helpful! Thanks so much for sharing this.

                                                In case anyone is interested, I added this little nugget to the beginning of the script to check and disable tab-to-transient before it runs

                                                if (sf.ui.proTools.getMenuItem('Options', 'Tab to Transient').isMenuChecked)
                                                {
                                                    //Tab to Transient is enabled - disable it
                                                    sf.ui.proTools.menuClick({
                                                    menuPath: ["Options","Tab to Transient"],
                                                });
                                                }
                                                else 
                                                {
                                                    //Tab to Transient is not enabled - good!
                                                };
                                                

                                                This code was just pinched from an old Andrew Scheps bounce script :-)

                                                -nick

                                            • D
                                              Davide Favargiotti @dieffe
                                                2018-07-17 15:01:10.647Z2018-07-17 15:14:29.111Z

                                                This is my modified version that moves the muted clips to a new track (created by the script).

                                                // This script moves all muted clips from the currently selected track to a new track, named as the original with the suffix _MUTED_CLIPS
                                                // It includes code from Oliver Momm, Christian Scheuer
                                                // Note: This version doesn't catch clips with sync points, it will be improved though
                                                // Also it doesn't mantain fades in the moved clips. You may have to run it twice to remove all the little regions created from the muted fades. 
                                                
                                                
                                                
                                                var origTrackName = sf.ui.proTools.selectedTrack.normalizedTrackName;
                                                var mutedTrackName = origTrackName + '_MUTED_CLIPS';
                                                
                                                // Check if the destination track already exist
                                                if (sf.ui.proTools.trackGetByName({ name: mutedTrackName, makeVisible: false }).track)
                                                {
                                                    log('Destination track already exist', 'Moving the muted clips to '+ mutedTrackName);
                                                }
                                                else{	
                                                sf.ui.proTools.trackDuplicateSelected({duplicateActivePlaylist: false});
                                                sf.ui.proTools.selectedTrack.trackRename({newName: mutedTrackName});
                                                sf.ui.proTools.trackSelectByName({names: [origTrackName]});
                                                }
                                                
                                                
                                                
                                                // Check if track is selected
                                                if (!sf.ui.proTools.getMenuItem('Track', 'Make Inactive').isEnabled) {
                                                    return;
                                                }
                                                else {
                                                    // "Return" key to go to start of session
                                                    sf.keyboard.press({
                                                        keys: 'return'
                                                    });
                                                
                                                    // Select first clip
                                                    sf.keyboard.press({
                                                        keys: 'shift+tab'
                                                    });
                                                
                                                    // Repeat while audio is still selected
                                                    while (sf.ui.proTools.getMenuItem('Clip', 'Group').isEnabled) {
                                                
                                                        var clipIsMuted = sf.ui.proTools.hasMenuItem('Edit', 'Unmute Clips');
                                                        var clipIsUnmuted = sf.ui.proTools.hasMenuItem('Edit', 'Mute Clips');
                                                        var noClips = sf.ui.proTools.hasMenuItem('Edit', 'Mute');
                                                
                                                        if (clipIsMuted) {
                                                            // Clip is muted
                                                            // Move the clip to the destination track. Change 'Cut' to 'Copy' if you want to copy the muted clips 
                                                            sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Cut'] });
                                                			sf.ui.proTools.trackSelectByName({names: [mutedTrackName]});
                                                			sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Paste'] });
                                                			sf.keyboard.press({keys: 'tab'});
                                                			sf.ui.proTools.trackSelectByName({names: [origTrackName]});
                                                        }
                                                        else if (clipIsUnmuted || noClips) {
                                                            // Skip clip
                                                            sf.keyboard.press({
                                                                keys: 'tab'
                                                            });
                                                        }
                                                
                                                        // Select next clip
                                                        sf.keyboard.press({
                                                            keys: 'shift+tab'
                                                        });
                                                    }
                                                
                                                    log('Moved Muted Clips', 'All muted clips moved to '+ mutedTrackName);
                                                }
                                                
                                                // Go to start of session
                                                sf.keyboard.press({
                                                    keys: 'return'
                                                });
                                                

                                                note that you may ned to run the script twice to remove some muted clips that remain on the source track (the fades in of the muted clips)

                                                1. AAnne Jimkes @Anne_Jimkes
                                                    2020-02-20 23:28:14.896Z

                                                    Hey!
                                                    Thanks for this great script.
                                                    The only issue I had when trying to use it, was that it didn't actually move the muted clips to the newly created track. In order to fix that I actually added a "move playhead to track below" (;) and "move playhead to track above" (p) around the paste actions:

                                                            sf.keyboard.press({
                                                                keys: "semicolon",
                                                            });
                                                    
                                                            sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Paste'] });
                                                            sf.keyboard.press({ keys: 'tab' });
                                                    
                                                            sf.keyboard.press({
                                                                keys: "p",
                                                            });
                                                    

                                                    I'm still trying to figure out if it would be possible to select all tracks at once and have all muted clips move to one or two "MUTED CLIPS TRACKs" at the bottom of the session.
                                                    I'm not a programmer so tips are very welcome!

                                                    Thanks :)

                                                    1. Anne, that's a great idea. It should be possible using a combination of a few scripts around here - please feel free to open a new thread for this so we can discuss options there.

                                                  • B
                                                    Tamás Bohács @bohitomi
                                                      2023-02-26 08:01:28.371Z

                                                      Thanks, everyone, for making this script!
                                                      I made an updated version which goes down and loops itself until the end of the session.
                                                      However, you must make an inactive track at the end to stop it.
                                                      Does anyone have an idea how to stop it, maybe achieve this in other ways?
                                                      Also, has anyone found a solution to recognize clips with sync points?

                                                      // This script clears all muted clips from the currently selected track, moves to the next track until the end of the session
                                                      // Note: you have to have an inactive track at the bottom
                                                      
                                                      while (true) {
                                                        // Check if track is selected
                                                        if (!sf.ui.proTools.getMenuItem('Track', 'Make Inactive').isEnabled) {
                                                            break;
                                                        }
                                                        else {
                                                            // "Return" key to go to start of session
                                                            sf.keyboard.press({
                                                                keys: 'return'
                                                            });
                                                      
                                                            // Select first clip
                                                            sf.keyboard.press({
                                                                keys: 'shift+tab'
                                                            });
                                                      
                                                            // Repeat while audio is still selected
                                                            while (sf.ui.proTools.getMenuItem('Clip', 'Group').isEnabled) {
                                                      
                                                                var clipIsMuted = sf.ui.proTools.hasMenuItem('Edit', 'Unmute Clips');
                                                                var clipIsUnmuted = sf.ui.proTools.hasMenuItem('Edit', 'Mute Clips');
                                                                var noClips = sf.ui.proTools.hasMenuItem('Edit', 'Mute');
                                                      
                                                                if (clipIsMuted) {
                                                                    // Clip is muted
                                                                    // Delete clip
                                                                    sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Clear'] });
                                                      
                                                                    // "Option+Shift+Tab" keys to extend selection to previous Clip-boundary
                                                                    sf.keyboard.press({
                                                                        keys: 'alt+shift+tab'
                                                                    });
                                                                }
                                                                else if (clipIsUnmuted || noClips) {
                                                                    // Skip clip
                                                                    sf.keyboard.press({
                                                                        keys: 'tab'
                                                                    });
                                                                }
                                                      
                                                                // Select next clip
                                                                sf.keyboard.press({
                                                                    keys: 'shift+tab'
                                                                });
                                                            }
                                                      
                                                            log('Clear Muted Clips', 'All muted clips cleared from this track');
                                                      
                                                            // Go to start of session
                                                            sf.keyboard.press({
                                                                keys: 'return'
                                                            });
                                                      
                                                            // Select next track
                                                            sf.keyboard.press({
                                                                keys: 'semicolon'
                                                            });
                                                      
                                                            // Check if there are any more tracks
                                                            if (!sf.ui.proTools.getMenuItem('Track', 'Make Inactive').isEnabled) {
                                                                break;
                                                            }
                                                        }
                                                      }