No internet connection
  1. Home
  2. How to

Mute Tracks By Specific Name

I would love to be able to specify the track name to mute as an alternative to getting a search window. I would use this to mute/unmute guide tracks.

Solved in post #2, click to view
  • 27 replies

There are 27 replies. Estimated reading time: 15 minutes

  1. Hi @sbiss.

    You can use this code to toggle the Mute state of the track named "GUIDE":

    sf.ui.proTools.trackGetByName({
        name: 'GUIDE',
        makeVisible: true
    }).track.buttons.getByTitle('Mute').elementClick();
    

    Does that fit what you had in mind?

    Reply1 LikeSolution
    1. And if you need to not toggle, but to set the mute state to something specific, use this (this script also supports setting for more than one track at a time):

      function setMuteState(trackNames, value) {
          for (var i=0; i<trackNames.length; i++) {
              var muteBtn = sf.ui.proTools.trackGetByName({
                  name: trackNames[i],
                  makeVisible: true
              }).track.buttons.getByTitle('Mute');
              if ((muteBtn.invalidate().value.value === "on state") !== value)
                  muteBtn.elementClick();
          }
      }
      setMuteState([ 'GUIDE1', 'GUIDE2' ], true); //to mute them
      setMuteState([ 'GUIDE1', 'GUIDE2' ], false); //to un-mute them
      
    2. S
      In reply tosbiss:

      Yes, that's exactly what I was looking for. Nice to have that ability on the keyboard. Thanks!

      1. S
        In reply tosbiss:

        Having some trouble getting the 2nd example to work. Looks like the last two lines are just an example of how I would change the code in the 1st line? So, for instance I would change the 1st line to:

        function setMuteState([ 'MX GT', 'DX GT' ], true) {

        1. Sorry @sbiss I should have commented this code better.

          The last two lines are examples that are mutually exclusive. They both call the function, which should be left untouched.

          So this would be one example - mute GUIDE1 and GUIDE2:

          function setMuteState(trackNames, value) {
              for (var i=0; i<trackNames.length; i++) {
                  var muteBtn = sf.ui.proTools.trackGetByName({
                      name: trackNames[i],
                      makeVisible: true
                  }).track.buttons.getByTitle('Mute');
                  if ((muteBtn.invalidate().value.value === "on state") !== value)
                      muteBtn.elementClick();
              }
          }
          setMuteState([ 'GUIDE1', 'GUIDE2' ], true); //to mute them
          

          This would unmute GUIDE1 and GUIDE2:

          function setMuteState(trackNames, value) {
              for (var i=0; i<trackNames.length; i++) {
                  var muteBtn = sf.ui.proTools.trackGetByName({
                      name: trackNames[i],
                      makeVisible: true
                  }).track.buttons.getByTitle('Mute');
                  if ((muteBtn.invalidate().value.value === "on state") !== value)
                      muteBtn.elementClick();
              }
          }
          setMuteState([ 'GUIDE1', 'GUIDE2' ], false); //to unmute them
          
          1. Further (just to clarify the syntax), to unmute even more tracks, you just separate with commas:

            setMuteState([ 'GUIDE1', 'GUIDE2', 'GUIDE3', 'GUIDE4' ], false);
            

            The true means mute, false means unmute - in this case.

        2. S
          In reply tosbiss:

          Got it. Works perfectly. Not sure how I'd use this one, but good to have :)

          1. Great to hear - thanks Steve!

          2. S
            In reply tosbiss:

            And in the 1st example that toggles the mute (more useful to me), how would I alter the code to toggle mute on multiple tracks?

            1. This depends on which functionality you'd like.

              The simple cases are easy:

              • If all are muted, unmute all
              • If all are unmuted, mute all

              But what if only some are muted. Then toggle each one individually? Or, if any single one is muted, unmute all, else, mute all?

              1. Pro Tools just toggles each one individually.

                Toggling individually would be like this:

                function toggleMuteStateIndividually(trackNames) {
                    trackNames.forEach(function (trackName) {
                        var muteBtn = sf.ui.proTools.trackGetByName({
                            name: trackName,
                            makeVisible: true
                        }).track.buttons.getByTitle('Mute');
                        muteBtn.elementClick();
                    });
                }
                toggleMuteStateIndividually(['GUIDE1', 'GUIDE2']);
                

                Toggling as a group (so after invoking, either all are muted or unmuted):

                function toggleMuteStateAsGroup(trackNames) {
                    var tracks = trackNames.map(function (trackName) {
                        return sf.ui.proTools.trackGetByName({
                            name: trackName,
                            makeVisible: true
                        }).track;
                    });
                    var newValue = !tracks.some(function(track){ return track.buttons.getByTitle('Mute').invalidate().value.value === "on state" });
                
                    for (var i = 0; i < tracks.length; i++) {
                        var muteBtn = tracks[i].buttons.getByTitle('Mute');
                        if ((muteBtn.invalidate().value.value === "on state") !== newValue)
                            muteBtn.elementClick();
                    }
                }
                toggleMuteStateAsGroup(['GUIDE1', 'GUIDE2']);
                
                1. In reply tochrscheuer:

                  Good point! It's more likely I would use a VCA to mute toggle a group of tracks, and I have those already set up in my template. I guess if I were to use something like this I would probably want to force them all to the same state. So make them all muted, regardless of their initial state. But I think a VCA is a better solution in this case, since it can mute/unmute tracks without changing the state of the children tracks.

                  1. Yea, agreed. Maybe it would make sense in some stem routing scenario etc.
                    But in any case what you'd go for if you wanted to do without VCA is my toggleMuteStateAsGroup code from above.

                    1. Would you mind if I move this to the public "How to" section so other users can find it in the future? It has some code examples that would be nice to share :)

              2. S
                In reply tosbiss:

                Cool. Good to have the option available :)

                1. S
                  In reply tosbiss:

                  Sorry just saw you post about moving to the public "How To". Please do! I've made F16-19 my GT Master - DX - MX - FX and it's really efficient.

                  1. Loving this!
                    I'm thinking, now that you're diving more deeply into the platform. At some point you should look quickly through some of the other How to... threads and see if you get inspired by some of the questions in there. Lmk if you need any help understanding how to use the code without coding (eg. maybe some of the scripts will just need a little tweak or two before you can use them).

                  2. S
                    In reply tosbiss:

                    I've attempted writing some code using auto-complete, but it's still a little out of my league. I think you need at least a basic background in coding even with that option. But I'm able to adapt existing code if it's simple. I've looked through the how to section and found some interesting stuff. But I'll check back to see what's there. FYI - I was just talking you up again to Danny Caccavo, who is the Pro Tools guru here. I'd really like to show him and the rest of the team what you're doing. And they have a few people here who can code who could certainly do some cool stuff with this platform. They are insanely busy, but I think interested in checking it out. Perhaps we can get you on a Skype call or something if we can find a time. Would you be interested in that?

                    1. Yes certainly - that's great to hear. I've been meaning to reach back out for a while, I'm sure we would have lots of interesting stuff to talk about. Let's set it up - but let's take the discussion on email instead of here (since this thread is now public).

                      1. Sounds good.

                    2. S
                      In reply tosbiss:

                      This command is great! I'm muting my DX, MX, and FX GT's from my keyboard. BUT it does not work for one track and I cannot figure out why. The track is called "ALL FX". I copied/pasted the code and replaced the track name with ALL FX. But each time it fails Javascript exception: TypeError. I can send screen shots if it helps. Here's the code:

                      sf.ui.proTools.trackGetByName({
                      name: ' ALL FX',
                      makeVisible: true
                      }).track.buttons.getByTitle('Mute').elementClick();

                      1. Hi @sbiss. It looks like you have an extra space in the start of the track name: ' ALL FX' should be 'ALL FX'

                        1. Doh! All the other tracks have a space before the name so I copied pasted, not remembering I'd named the tracks that way intentionally. Strange, thought I'd tried removing the space. Sorry for the bother.

                          1. No worries - this is what the forum is for :) Glad you got it working.

                            1. The real issue here is that you don't get a better error message actually. I'll report this as a bug, since I believe we can improve this.

                      2. M
                        In reply tosbiss:
                        Martin Pavey @Martin_Pavey
                          2024-01-31 13:36:34.825Z

                          This is great for muting/Un muting multiple Busses offscreen.
                          Thanks guys!

                          1. S2
                            In reply tosbiss:
                            Sreejesh Nair @Sreejesh_Nair
                              2024-02-15 10:42:34.747Z2024-02-15 12:29:40.013Z

                              This code will cycle the mute through the tracks names. I use this to monitor various downmixes. You can provide the track names in the var headphoneTracks part in the beginning of the code. If by mistake all are muted, then the first track in the list will be unmuted. If there are more than 2 tracks unmuted, then too all except the first track in the list will be muted. If only one is unmuted, then it will begin the cyclic toggle between the rest.

                              var headphoneTracks = ['Binaural', 'AppleMusic', 'Surround']; // Add more track names as needed
                              
                              function toggleHeadphoneMute() {
                                  // Determine the mute state of each track and count how many are unmuted
                                  var unmutedTracks = headphoneTracks.filter(function(trackName) {
                                      var muteState = sf.ui.proTools.trackGetByName({
                                          name: trackName,
                                          makeVisible: true
                                      }).track.buttons.getByTitle('Mute').invalidate().value.value;
                                      return muteState !== "on state"; 
                                  });
                              
                                  // Logic to handle different mute state scenarios
                                  if (unmutedTracks.length === 0) {
                                      // If all tracks are muted, unmute the first one
                                      toggleMuteState(headphoneTracks[0]);
                                  } else if (unmutedTracks.length > 1) {
                                      // If more than one track is unmuted, mute all except the first one
                                      unmutedTracks.forEach(function(trackName, index) {
                                          if (index > 0) toggleMuteState(trackName); // Skip the first track
                                      });
                                  } else {
                                      // If exactly one track is unmuted, cycle the mute state to the next track
                                      var currentIndex = headphoneTracks.indexOf(unmutedTracks[0]);
                                      var nextIndex = (currentIndex + 1) % headphoneTracks.length; // Cycle through the array
                                      toggleMuteState(unmutedTracks[0]); // Mute the currently unmuted track
                                      toggleMuteState(headphoneTracks[nextIndex]); // Unmute the next track
                                  }
                              }
                              
                              function toggleMuteState(trackName) {
                                  // Toggles the mute state of a given track
                                  sf.ui.proTools.trackGetByName({
                                      name: trackName,
                                      makeVisible: true
                                  }).track.buttons.getByTitle('Mute').elementClick();
                              }
                              
                              // Activate Pro Tools main window and run the toggle function
                              sf.ui.proTools.appActivateMainWindow();
                              sf.ui.proTools.invalidate();
                              toggleHeadphoneMute();
                              
                              1. Progress
                              2. @chrscheuer marked this topic as Planned 2018-11-02 17:43:22.195Z.
                              3. @chrscheuer marked this topic as Started 2018-11-02 17:43:22.959Z.
                              4. @chrscheuer marked this topic as Done 2018-11-02 17:43:23.790Z.
                              5. @chrscheuer closed this topic 2018-11-02 17:43:38.549Z.
                              6. @chrscheuer reopened this topic 2018-11-02 17:43:40.217Z.