No internet connection
  1. Home
  2. How to

How to toggle input monitoring state of a track

By Yujiro Yonetsu @Yujiro_Yonetsu
    2020-11-04 15:11:22.299Z

    Hello

    I want to audition between the previous mix and the current mix.

    I just need to be able to select a specific track and toggle the input of it, but please tell me how.

    I could have had certain tracks selected.

    function getGroupListItem(name) {
        var groupList = sf.ui.proTools.mainWindow.tables.whoseTitle.contains('Group').first;
        return groupList.childrenByRole("AXRow").allItems.map(function (r) {
            return {
                row: r,
                selectBtn: r.childrenByRole("AXCell").first.children.first,
                name: r.childrenByRole("AXCell").allItems[1].children.first.title.value.match(/^.+ - ([^(]+)/)[1].replace(/ $/, ''),
            };
        }).filter(function (r) { return r.name == name })[0];
    }
    
    var groupListItem = getGroupListItem("PrintMaster");
    groupListItem.selectBtn.elementClick();
    

    I don't know how to toggle the input from here.
    I can see that I would prefer not to use the Shift+I method.
    please help me.

    Solved in post #9, click to view
    • 24 replies

    There are 24 replies. Estimated reading time: 17 minutes

    1. Yujiro Yonetsu @Yujiro_Yonetsu
        2020-11-05 16:52:17.867Z

        I've tried and tried and tried, but it doesn't work. What is wrong with it?

        function getGroupListItem(name) {
            var groupList = sf.ui.proTools.mainWindow.tables.whoseTitle.contains('Group').first;
            return groupList.childrenByRole("AXRow").allItems.map(function (r) {
                return {
                    row: r,
                    selectBtn: r.childrenByRole("AXCell").first.children.first,
                    name: r.childrenByRole("AXCell").allItems[1].children.first.title.value.match(/^.+ - ([^(]+)/)[1].replace(/ $/, ''),
                };
            }).filter(function (r) { return r.name == name })[0];
        
        
        var groupListItem = getGroupListItem("PrintMaster");
        groupListItem.selectBtn.elementClick();
        
         var inputBtn = track.buttons.whoseTitle.is('TrackInput Monitor').first;
            inputBtn.elementClick();
        }
        
            inputBtn("PrintMaster")
        
        
        1. Hi Yujiro.

          I can see you're using code that works with Groups. Is there any specific reason for that? From as far as I can see, all you want to do is to toggle the Input Monitor state of just one track, right?

          This script here would toggle the Input Monitoring mode of the track with the name "PrintMaster":

          function trackToggleInput(trackName) {
              var track = sf.ui.proTools.trackGetByName({ name: trackName }).track;
              var inputBtn = track.buttons.whoseTitle.is('TrackInput Monitor').first;
              inputBtn.elementClick();
          }
          
          trackToggleInput('PrintMaster');
          
          1. Yujiro Yonetsu @Yujiro_Yonetsu
              2020-11-05 21:28:34.518Z

              Thanks for the script.

              But I did so for a reason.
              The name of the track to be printed changes every time because I want to include the name of the song.
              We want to make it work with the group name so that it can be used commonly there.

              please help me

              1. Can you clarify a bit more? So the group would have just one track, whose input monitor you want to toggle? Or does the group contain more than one track?

                1. Yujiro Yonetsu @Yujiro_Yonetsu
                    2020-11-06 23:04:03.245Z

                    Okay.

                    My Mix printed to one audio track.
                    All track out assigned to this track.
                    What I'm monitoring is this print track out.

                    The name of the track name includes the title and version of the song.
                    ex.
                    Song01_Mix1.0

                    Each time I work on a mix, the version is updated, and it accumulates in a playlist on the print track.
                    This script should come into play when I want to compare the sound of past versions of a mix with the current mix.
                    The input button on the print track can be toggled to make this happen.

                    Since the track names in the print track change every time, we felt it was not a good idea to limit them in the script, so we chose to select them by group name.
                    If you can select a specific track in a name-independent way, that's fine too.

                    (I've read
                    "Toggle input state of track by name" thread.
                    In my case, the truck isn't set to be at the far end, so I need a unique method.)

                    1. Thank you so much for those details. We could still select them by group - but using a name search would make the script a lot faster and more robust.
                      For example - does the mix/master track always contain the text "_Mix"? If that's the case, then we can use that to find the track :)

                      1. Yujiro Yonetsu @Yujiro_Yonetsu
                          2020-11-07 14:30:46.038Z

                          Okay
                          I understand your comment.

                          I make naming rule now.
                          Always my naming include "[Mix"
                          Can you tell me the script for that?

                          And for my study, I'd like to know how to specify by the group name of my original purpose.
                          I think the difference will help us understand it better.

                          Best regard

                          1. Christian Scheuer @chrscheuer2020-11-08 11:08:42.330Z2020-11-08 11:18:39.679Z

                            This should do it:

                            /**@param {string} partialTrackName */
                            function getFirstTrackContaining(partialTrackName) {
                                return sf.ui.proTools.visibleTrackHeaders.filter(th => th.normalizedTrackName.includes(partialTrackName))[0];
                            }
                            
                            /**@param {AxPtTrackHeader} track */
                            function trackToggleInput(track) {
                                var inputBtn = track.buttons.whoseTitle.is('TrackInput Monitor').first;
                                inputBtn.elementClick({}, `Couldn't find track input button`);
                            }
                            
                            function main() {
                                let track = getFirstTrackContaining('[Mix');
                                if (!track) throw `Couldn't find a Mix track\nPlease make sure the track is visible`;
                            
                                trackToggleInput(track);
                            }
                            
                            main();
                            

                            The group script would need to select the track, like this (but could also be made to restore the track selection afterwards):

                            
                            function getGroupListItem(groupName) {
                                var groupList = sf.ui.proTools.mainWindow.tables.whoseTitle.contains('Group').first;
                                if (!groupList.exists) throw `Couldn't find Group List`;
                                return groupList.childrenByRole("AXRow").allItems.map(function (r) {
                                    return {
                                        row: r,
                                        selectBtn: r.childrenByRole("AXCell").first.children.first,
                                        name: r.childrenByRole("AXCell").allItems[1].children.first.title.value.match(/^.+ - ([^(]+)/)[1].replace(/ $/, ''),
                                    };
                                }).filter(function (r) { return r.name == groupName })[0];
                            }
                            
                            function selectTracksInGroup(groupName) {
                                var groupListItem = getGroupListItem(groupName);
                                if (!groupListItem) throw `Couldn't find group "${groupName}"`;
                                groupListItem.selectBtn.elementClick({}, `Couldn't select tracks in group "${groupName}"`);
                            }
                            
                            /**@param {AxPtTrackHeader} track */
                            function trackToggleInput(track) {
                                var inputBtn = track.buttons.whoseTitle.is('TrackInput Monitor').first;
                                inputBtn.elementClick({}, `Couldn't find track input button`);
                            }
                            
                            function main() {
                                selectTracksInGroup('PrintMaster');
                            
                                trackToggleInput(sf.ui.proTools.selectedTrack);
                            }
                            
                            main();
                            
                            ReplySolution
                            1. Yujiro Yonetsu @Yujiro_Yonetsu
                                2020-11-08 11:13:29.532Z

                                Thank you so much!
                                I will compare and study the two methods you have taught me.

                                Thank you!

                                1. In reply tochrscheuer:
                                  NNick Agee @Nick_Agee
                                    2024-11-01 22:54:57.432Z

                                    Hey guys, I've been using this script for a while now to toggle input monitor on my print track (my print track name ends with Mix_v#). Its always worked great no matter what window view I'm on. But a few days ago I started to get this error message

                                    Any ideas?? Thank you for your time

                                    /**@param {string} partialTrackName */
                                    function getFirstTrackContaining(partialTrackName) {
                                        return sf.ui.proTools.visibleTrackHeaders.filter(th => th.normalizedTrackName.includes(partialTrackName))[0];
                                    }
                                    
                                    /**@param {AxPtTrackHeader} track */
                                    function trackToggleInput(track) {
                                        var inputBtn = track.buttons.whoseTitle.is('TrackInput Monitor').first;
                                        inputBtn.elementClick({}, `Couldn't find track input button`);
                                    }
                                    
                                    function main() {
                                        let track = getFirstTrackContaining('Mix_v');
                                        if (!track) throw `Couldn't find a Mix track\nPlease make sure the track is visible`;
                                    
                                        trackToggleInput(track);
                                    }
                                    
                                    main();```
                                    1. @Nick_Agee, if you upgraded to PT 2024.10 then you'll need to adjust Line 8 to this:

                                      const inputBtn = track.buttons.whoseTitle.startsWith('Input monitoring ').first; // PT2024.10+
                                      
                                      1. NNick Agee @Nick_Agee
                                          2024-11-02 03:52:05.065Z

                                          Perfect, that was it! Thank you!

                                        • In reply toNick_Agee:

                                          Hi Nick,

                                          I think the title of that button changed in PT 2024.10. Be sure to use the UI picker to get updated information about what the "TrackInput Monitor" button is called now.

                                          1. Oops didn't see the existing replies, my bad :)

                            2. In reply tochrscheuer:
                              Mike Wax @mikewax
                                2022-09-22 23:09:52.559Z

                                How would I make this work using the selected track instead of getting the track by name?
                                Thank you!

                                1. Change var track = sf.ui.proTools.trackGetByName({ name: trackName }).track; to var track = sf.ui.proTools.selectedTrack;

                                2. In reply tochrscheuer:
                                  Jack Green @Jack_Green
                                    2025-01-07 15:40:51.413Z

                                    Im having a problem with the above function after updating protools to 2024.10.2 and sound flow 5.10.0

                                    function trackToggleInput(trackName) {
                                        var track = sf.ui.proTools.trackGetByName({ name: trackName }).track;
                                        var inputBtn = track.buttons.whoseTitle.is('TrackInput Monitor').first;
                                        inputBtn.elementClick();
                                    }
                                    
                                    function sessionIM() {
                                    
                                        sf.ui.proTools.appActivateMainWindow();
                                    
                                        let trackNames = sf.ui.proTools.trackNames;
                                        setGroupActiveOrInactive("IM/REC", true);
                                    
                                        if (trackNames.includes("_ST MIX")) {
                                            trackToggleInput("_ST MIX")
                                        }
                                    
                                        if (trackNames.includes("_LRMIX")) {
                                            trackToggleInput("_LRMIX")
                                        }
                                    }
                                    
                                    sessionIM();
                                    

                                    Here is my version.

                                    Im getting this error

                                    ClickButtonAction requires UIElement (Mix Tool Functions: Line 64)
                                    Couldn't get item #0 as the array length was 0 - sf.ui.app('com.avid.ProTools').<unknown>.<unknown>.<unknown>.buttons.whoseTitle.is('TrackInput Monitor').first (AxElementArrayIndexedItem)
                                    

                                    line 64 in this script (Which just holds lots of functions for use in various scripts) is...

                                    inputBtn.elementClick();
                                    

                                    Thanks in advance !

                                    1. In reply toJack_Green:

                                      I think it's likely the button is no longer called "TrackInput Monitor". Try using the UI picker in your script to verify its name is updated correctly.

                                      1. Jack Green @Jack_Green
                                          2025-01-07 15:54:48.603Z

                                          Thanks for getting back so quick.

                                          Correct looks like the input path button definition has changed

                                          sf.ui.proTools.trackGetByName({ name: '_LV Orch 5' }).track.buttons.whoseTitle.is("Input monitoring disabled").first as an example
                                          

                                          Or

                                          sf.ui.proTools.trackGetByName({ name: '_51MIX' }).track.buttons.whoseTitle.is("Input monitoring enabled").first
                                          
                                          

                                          I'll work on a fix Tomorrow. I think I have an idea (if someone else doesn't beat me to it!)

                                          1. Jack Green @Jack_Green
                                              2025-01-07 16:35:08.846Z

                                              Managed to find 20 minutes. Here's what I got. I imagine someone will be along soon todo the same thing is half the lines ! haha

                                              /**
                                               * @param {string} trackName
                                               * @param {"On"|"Off"|"Toggle"} value
                                               */
                                              function trackToggleInput(trackName, value) {
                                                  var track = sf.ui.proTools.trackGetByName({ name: trackName }).track;
                                              
                                                  var inputBtn = undefined
                                                  if (track.buttons.whoseTitle.is("Input monitoring enabled").first.exists) inputBtn = track.buttons.whoseTitle.is("Input monitoring enabled").first
                                                  if (track.buttons.whoseTitle.is("Input monitoring disabled").first.exists) inputBtn = track.buttons.whoseTitle.is("Input monitoring disabled").first
                                              
                                                  if (value == "Toggle") inputBtn.elementClick();
                                                  if (value == "On" && track.buttons.whoseTitle.is("Input monitoring disabled").first.exists) inputBtn.elementClick();
                                                  if (value =="Off" && track.buttons.whoseTitle.is("Input monitoring enabled").first.exists) inputBtn.elementClick();
                                              }
                                              

                                              Allows you to toggle or set as on or off.

                                              Hope this helps someone.

                                              Jack

                                              1. Hors Piste @Hors_Piste
                                                  2025-05-10 16:00:29.680Z

                                                  is there any way to choose to always toggle the first OR the last track of a session ?

                                                  I used to use this script but it doesn't work anymore...

                                                  /**
                                                   * @param {string} trackName
                                                   * @param {"On"|"Off"|"Toggle"} value
                                                   */
                                                  function trackToggleInput(trackName, value) {
                                                      var track = sf.ui.proTools.trackGetByName({ name: trackName }).track;
                                                  
                                                      var inputBtn = undefined
                                                      if (track.buttons.whoseTitle.is("Input monitoring enabled").first.exists) inputBtn = track.buttons.whoseTitle.is("Input monitoring enabled").first
                                                      if (track.buttons.whoseTitle.is("Input monitoring disabled").first.exists) inputBtn = track.buttons.whoseTitle.is("Input monitoring disabled").first
                                                  
                                                      if (value == "Toggle") inputBtn.elementClick();
                                                      if (value == "On" && track.buttons.whoseTitle.is("Input monitoring disabled").first.exists) inputBtn.elementClick();
                                                      if (value =="Off" && track.buttons.whoseTitle.is("Input monitoring enabled").first.exists) inputBtn.elementClick();
                                                  }```
                                                  
                                                  
                                      2. C
                                        In reply toYujiro_Yonetsu:

                                        You could select that track by the input name this one will always stays.

                                        1. S
                                          In reply toYujiro_Yonetsu:
                                          Sebastian @Sebastian
                                            2025-02-12 15:36:53.740Z2025-02-13 10:05:24.676Z

                                            Hi,

                                            is there a fix to this scrip, now that the name of Input Monitoring seems to have changed?
                                            Thanks for the help.

                                            Best
                                            Sebastian

                                            sf.ui.proTools.selectedTrack.buttons.whoseTitle.is("Input monitoring disabled").first
                                            function toggleInput(trackName) {
                                                var track = sf.ui.proTools.invalidate().trackGetByName({
                                                    name: trackName,
                                                    makeVisible: true,
                                                }).track;
                                            
                                                var inputBtn = track.buttons.whoseTitle.is('TrackInput Monitor').first;
                                                inputBtn.elementClick();
                                            }
                                            
                                            function toggleInputOfLastTrack() {
                                                var lastTrackName = sf.ui.proTools.trackNames.slice(-1)[0];
                                                toggleInput(lastTrackName);
                                            }
                                            
                                            toggleInputOfLastTrack();
                                            
                                            1. Hors Piste @Hors_Piste
                                                2025-05-10 15:54:56.772Z

                                                it would be awesome