No internet connection
  1. Home
  2. How to

Set track to 0.0 db

By Chip Sloan @ChipSloan
    2020-08-15 21:47:02.315Z

    I'm trying to figure out a script to set a track to a fader value of 0.0 dB. I use a master fader for a eucon master and it's be great to have a set to zero shortcut. I found the code to find the track by name but can't quite figure out how to set fader to zero.

    Any help?

    Solved in post #4, click to view
    • 22 replies

    There are 22 replies. Estimated reading time: 14 minutes

    1. This script will Option-Click on the volume display of the selected track in the Edit window, to reset the volume to 0.0 for that track:

      sf.ui.proTools.selectedTrack.groups.whoseTitle.is("Audio IO").first.sliders.whoseTitle.is('Volume').first.mouseClickElement({
          isOption: true,
      });
      

      This does the same for a track named "Eucon Master" by first scrolling the track into view, then option-clicking its volume display:

      
      const track = sf.ui.proTools.trackGetByName({
          name: 'Eucon Master'
      }).track;
      
      track.trackScrollToView();
      
      track.groups.whoseTitle.is("Audio IO").first.sliders.whoseTitle.is('Volume').first.mouseClickElement({
          isOption: true,
      });
      
      1. UUdi Simhon @Udi_Simhon
          2024-01-01 08:10:19.561Z

          Hi Christian Scheuer
          @chrscheuer
          Can you please modify the first script to to -3db reduction of level to the selected track?

          Thanks!

          Udi

          1. Andrew Scheps @Andrew_Scheps
              2024-01-01 08:39:51.588Z

              Hi @Udi_Simhon ,

              That script uses option-click to set it to 0, so there's no version of it that will work to do relative levels. My script below would be the starting point, but you would have to read the level, do the math and then set the level. Not too involved. It would probably be better to make it for selected track as well to not have it hard coded (unless it's a template track you use all the time).

              If you want to try it yourself here's some untested code that might work. I'm not in front of Pro Tools to test.

              Change (from line 32):

              win.textFields.whoseTitle.is('Volume Numerical').first.elementClick();
                  sf.keyboard.type({ text: VOLUME });
                  sf.keyboard.press({ keys: 'enter' });
              

              to

              var volumeTextField = win.textFields.whoseTitle.is('Volume Numerical').first;
              var originalVolume = Number(volumeField.value.invalidate().value);
              var newVolume = originalVolume - 3;
              volumeTextField.elementClick();
                  sf.keyboard.type({ text: String(newVolume) });
                  sf.keyboard.press({ keys: 'enter' });
              

              Also, change line 1 to:

              const Target_Track = sf.ui.proTools.selectedTrackNames[0];
              

              If you want to do it to all selected tracks you would need get rid of the [0] and set up a for loop, remembering to scroll each track into view first.

              If this doesn't work out of the box I would suggest starting a new thread in the forum with a copy of my script and get somebody to add the bits you need.

              Happy new year!
              Andrew

              1. There's also possible inspiration to get in this command in our official Pro Tools package:

                1. DDavid Carey @David_Carey
                    2025-01-26 01:08:59.361Z

                    Is there a numeric value for -INF? Fader all the way down...

            • In reply toChipSloan:
              Chip Sloan @ChipSloan
                2020-08-17 17:11:32.960Z

                Great Thanks. Is there a command I can add to return the scroll to where it started?

                1. Unfortunately, I don't think we have that ability today.

                2. In reply toChipSloan:
                  Chip Sloan @ChipSloan
                    2020-08-17 21:33:56.167Z2020-08-18 00:56:42.283Z

                    For the record I could not get that to work in the Edit window. I did however get this to work for my track named "ST CR Master":

                    
                    sf.ui.proTools.trackGetByName({ name: "ST CR Level", makeVisible: true }).track.trackScrollToView();
                    
                    sf.ui.proTools.mainWindow.groups.whoseTitle.is('ST CR Level - Master Track ').first.groups.whoseTitle.is('Master IO').first.buttons.whoseTitle.is('Output Window button').first.elementClick();
                    
                    sf.ui.proTools.mainTrackOutputWindow.sliders.whoseTitle.is('Volume').first.elementClick({
                        isOption: true,
                    });
                    
                    

                    Thanks

                    C

                    ReplySolution
                    1. A
                      In reply toChipSloan:
                      Andy Daddario @Andy_Daddario
                        2020-09-01 17:21:39.240Z

                        Hi All, completely new here. I can see how to set the fader to 0. What if I wanted to set it to -10? Is there a way to do that? Specifically the MX Fader in my session if that helps.

                        I wrote an apple script to do this, but runs SO SLOW.....:)

                        Thanks!.....Andy

                        1. Hi Andy,

                          Didn't see your post here immediately as you replied to a closed/solved thread. The best way is to open a new thread linking to the old one as then I can see your thread would be marked unsolved, so I won't forget it :)

                          I think you can do something to implement this by combining our HUI emulation with preview reading/writing.
                          If you open up a new thread, I'll send you some scripts.

                        2. In reply toChipSloan:
                          Andrew Scheps @Andrew_Scheps
                            2020-09-01 22:50:34.703Z

                            This script will set the volume of the specified track to the specified volume, as set by the two constants at the top of the script, and then reselect the original track. You could make this more flexible by doing it on the selected track.

                            sf.ui.proTools.appActivateMainWindow();
                            
                            const TARGET_TRACK = "MX";
                            const VOLUME = '-10';
                            
                            
                            function setVolume() {
                                if (sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value !== 'open')
                                    sf.ui.proTools.selectedTrack.outputWindowButton.elementClick();
                            
                                var win = sf.ui.proTools.floatingWindows.allItems.filter(function (w) {
                                    return w.children.whoseTitle.is('Volume').exists;
                                })[0];
                            
                                win.textFields.whoseTitle.is('Volume Numerical').first.elementClick();
                                sf.keyboard.type({ text: VOLUME });
                                sf.keyboard.press({ keys: 'enter' });
                            
                            
                            }
                            
                            function main() {
                                //Save the name of the originally selected track
                                //And the selection
                                var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
                                var selection = sf.ui.proTools.selectionGetInSamples();
                            
                                //Select the desired track
                                sf.ui.proTools.trackSelectByName({ names: [TARGET_TRACK] });
                            
                                //Set the volume
                                setVolume();
                            
                               
                                //Select original track again
                                sf.ui.proTools.trackSelectByName({ names: [originalTrackName] });
                            }
                            
                            main();
                            
                            1. AAndy Daddario @Andy_Daddario
                                2020-09-02 01:33:19.412Z

                                Andrew, thank you so much for this, a complete newbie here.

                                I'm getting this one error, anything I need to do on my end?

                                Thanks!......Andy

                                1. Andrew Scheps @Andrew_Scheps
                                    2020-09-02 07:19:25.508Z

                                    I didn’t do any setup routine. I believe this is because you’re not showing I/O in the edit window.

                                    1. In reply toAndy_Daddario:
                                      Andrew Scheps @Andrew_Scheps
                                        2020-09-02 09:58:34.051Z

                                        This should be more robust:

                                        const TARGET_TRACK = "Audio 7";
                                        const VOLUME = '-10';
                                        sf.ui.proTools.appActivateMainWindow();
                                        const checkBoxes = [
                                            { Title: 'I/O', State: "Enable" },
                                        
                                        
                                        ];
                                        function setCheckboxState(item) {
                                            sf.ui.proTools.menuClick({
                                                menuPath: ['View', 'Edit Window Views', item.Title],
                                                targetValue: item.State,
                                                onError: "Continue",
                                            })
                                        }
                                        function setupScreen() {
                                            //Make sure I/O visible in Edit window
                                            checkBoxes.forEach(setCheckboxState);
                                        }
                                        
                                        
                                        function setVolume() {
                                            sf.ui.proTools.mainWindow.invalidate();
                                            if (sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value != 'open')
                                                sf.ui.proTools.selectedTrack.outputWindowButton.elementClick();
                                        
                                            var win = sf.ui.proTools.floatingWindows.allItems.filter(function (w) {
                                                return w.children.whoseTitle.is('Volume').exists;
                                            })[0];
                                        
                                            win.textFields.whoseTitle.is('Volume Numerical').first.elementClick();
                                            sf.keyboard.type({ text: VOLUME });
                                            sf.keyboard.press({ keys: 'enter' });
                                        
                                        
                                        }
                                        
                                        function main() {
                                            setupScreen();
                                            //Save the name of the originally selected track
                                        
                                            var originalTrackName = sf.ui.proTools.selectedTrackNames[0];
                                        
                                            //Select the desired track
                                            sf.ui.proTools.trackSelectByName({ names: [TARGET_TRACK] });
                                        
                                            //Set the volume
                                            setVolume();
                                        
                                           
                                            //Select original track again
                                            sf.ui.proTools.trackSelectByName({ names: [originalTrackName] });
                                        }
                                        
                                        main();
                                        
                                        
                                        1. AAndy Daddario @Andy_Daddario
                                            2020-09-03 05:34:13.399Z

                                            Terrific Andrew, I will give this a try when I'm back to my studio. Thanks so much and appreciate your taking the time to write this. Your script seems very detailed, I have a lot to learn.

                                            Thanks!......Andy

                                            1. In reply toAndrew_Scheps:
                                              AAndy Daddario @Andy_Daddario
                                                2020-09-06 02:26:45.619Z

                                                Andrew, it works beautifully, thank you so much!

                                                So now, how and why does it work? (as I try and learn the language). Are the // messages on what each command is doing?

                                                1. Andrew Scheps @Andrew_Scheps
                                                    2020-09-10 18:55:29.955Z

                                                    Hi Andy,

                                                    Yes, and line that has // in front of it is a comment

                                                    1. AAndy Daddario @Andy_Daddario
                                                        2020-09-14 17:15:28.241Z

                                                        Thanks so much for your help with this Andrew, much appreciated!

                                                    2. In reply toAndrew_Scheps:
                                                      RRyan Short @Ryan_Short
                                                        2021-04-27 23:13:34.717Z

                                                        Hey Andrew, love this code! Just trying to figure out how to make it work for whichever track(s) is selected currently, rather than just the "Audio 7" track specifically.. is that possible? Sorry in advance, only been using for a couple days now... Thank you!

                                                  • In reply toChipSloan:
                                                    Samuel Škubla @Samuel_Skubla
                                                      2020-09-10 20:10:05.160Z

                                                      Not script related, but I just found that tapping (not pressing) "Monitor" knob while holding ALT/OPT key will set assigned aster fader to 0dB.

                                                      1. E
                                                        In reply toChipSloan:
                                                        Enrique Larreal @Enrique_Larreal
                                                          2022-02-22 18:31:14.642Z

                                                          Is there a way to do this for all selected tracks?

                                                          1. SSreejesh Nair @Sreejesh_Nair
                                                              2024-01-03 08:16:19.218Z2024-01-04 19:16:58.914Z

                                                              This code will prompt for the user value and set it for all the selected tracks

                                                              const VOLUME = (sf.interaction.displayDialog({
                                                                  defaultAnswer: "-6",
                                                                  buttons: ["OK", "Cancel"],
                                                                  defaultButton: "OK",
                                                                  cancelButton: "Cancel",
                                                                  title: ("Volume Setter"),
                                                                  prompt: ("Enter Volume Value"),
                                                              })).text;
                                                              
                                                              
                                                              function setupScreenAndSetVolume() {
                                                                  // Make sure I/O visible in Edit window and set checkboxes
                                                                  ['I/O'].forEach(title => {
                                                                      sf.ui.proTools.menuClick({
                                                                          menuPath: ['View', 'Edit Window Views', title],
                                                                          targetValue: "Enable",
                                                                          onError: "Continue",
                                                                      });
                                                                  });
                                                              
                                                                  let outputWindowState = sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value;
                                                                  if (outputWindowState !== "open" && outputWindowState !== "output bypassed active open") {
                                                                      sf.ui.proTools.selectedTrack.trackOutputToggleShow();
                                                                  }
                                                              
                                                                  let win = sf.ui.proTools.floatingWindows.allItems.find(w => w.children.whoseTitle.is('Volume').exists);
                                                                  if (win) {
                                                                      win.textFields.whoseTitle.is('Volume Numerical').first.elementClick();
                                                                      sf.keyboard.type({ text: VOLUME });
                                                                      sf.keyboard.press({ keys: 'enter' });
                                                                  }
                                                              }
                                                              
                                                              sf.ui.proTools.appActivateMainWindow()
                                                              sf.ui.proTools.mainWindow.invalidate();
                                                              
                                                              // Save the names of the originally selected tracks and get all selected tracks
                                                              let originalTrackNames = sf.ui.proTools.selectedTrackNames;
                                                              let selectedTracks = sf.ui.proTools.selectedTrackHeaders;
                                                              
                                                              // Loop through each selected track and set the volume
                                                              selectedTracks.forEach(trackHeader => {
                                                                  sf.ui.proTools.trackSelectByName({ names: [trackHeader.normalizedTrackName], deselectOthers: true });
                                                                  setupScreenAndSetVolume();
                                                              });
                                                              
                                                              // Select original tracks again
                                                              sf.ui.proTools.trackSelectByName({ names: originalTrackNames });