No internet connection
  1. Home
  2. How to

How to automate the Bounce to Disk dialog

This script automates opening the Bounce to Disk dialog and changing the settings within.

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

There are 16 replies. Estimated reading time: 16 minutes

  1. //Invoke the File->Bounce to->Disk... menu item
    sf.ui.proTools.menuClickMenu({ menuPath: ['File', 'Bounce to', 'Disk...'] });
    
    //Wait for the 'Bounce' dialog to appear and assign it to the bounceDlg variable
    var bounceDlg = sf.ui.proTools.dialogWaitForManual({
        dialogTitle: 'Bounce'
    }).dialog;
    
    //Special code for now (this will change and be made easier)
    //What this does is get the Children of the bounceDialog, filter them so we only get the popupbuttons,
    //and then slice the resulting array so the we only get the last 4.
    //This is needed since there are no names/titles/labels on the 4 buttons used to set up file type, format, bit depth and
    //sample rate. We take the last 4, since the bounce sources will be the first X number of popup buttons in the dialogue,
    //but we don't know how many of those that there are.
    var popupButtons = bounceDlg.getElements("AXChildren").filter(function(e){ return e.fullRole == "AXPopUpButton" }).slice(-4);
    
    //Assign the four buttons coming out of the previous instruction to individual variables
    var fileTypeBtn = popupButtons[0];
    var formatBtn = popupButtons[1];
    var bitDepthBtn = popupButtons[2];
    var sampleRateBtn = popupButtons[3];
    
    //If the value is not already WAV, use the popupMenuSelect action to (1. click the button, 2. select the corresponding menuPath item in the popup menu)
    if (fileTypeBtn.value.value != 'WAV')
        fileTypeBtn.popupMenuSelect({ menuPath: ['WAV'] });
    
    if (formatBtn.value.value != 'Interleaved')
        formatBtn.popupMenuSelect({ menuPath: ['Interleaved'] });
    
    if (bitDepthBtn.value.value != '24 Bit')
        bitDepthBtn.popupMenuSelect({ menuPath: ['24 Bit'] });
    
    if (sampleRateBtn.value.value != '48 kHz')
        sampleRateBtn.popupMenuSelect({ menuPath: ['48 kHz'] });
    
    Reply3 LikesSolution
    1. ?@anon6770933309
        2018-06-16 13:55:42.136Z

        Great one!
        Question: How to access the Bounce Source pop up button?

        1. Thanks @Oli_Em. This is not currently possible. Link to idea tracker: https://forum.soundflow.org/-73/ability-to-access-bounce-source-in-bounce-to-disk-dialog

          1. ?@anon6770933309
              2018-06-16 14:21:26.115Z2018-06-16 15:26:43.498Z

              Thx, also for adding the idea.

              For those who need a workaround:

              // Invoke Bounce menu item
              sf.ui.proTools.getMenuItem('File', 'Bounce to', 'Disk...').elementClick();
              
              // Wait for the 'Bounce' dialog to appear and assign it to the bounceDlg variable
              var bounceDlg = sf.ui.proTools.dialogWaitForManual({
                  dialogTitle: 'Bounce'
              }).dialog;
              
              // Select pop up button for Bounce Source
              bounceDlg.mouseClickElement({
                  relativePosition: { x: 278, y: 51 }
              });
              

              From there you can navigate the menu with arrow up/down and return key commands and of course text (sf.keyboard.type). 😀

          2. In reply tochrscheuer:
            Kitch Membery @Kitch2019-09-14 08:29:25.459Z2019-09-14 09:13:31.798Z

            The above code was super helpful!

            Is there a way to uncheck the Add MP3 (checkbox) in the Bounce Dialog ? If this is checked, it greys out the MP3 only option in the File Type dropdown

            Thanks mate!
            Kitch

            1. Kitch Membery @Kitch2019-09-14 08:30:40.985Z2019-09-14 09:15:04.118Z

              This is the Checkbox I am refering to in my previous post. :-)

              1. Kitch Membery @Kitch2019-09-14 10:55:05.607Z

                Never mind... I worked it out. Was overthinking it. Easily done by using the "Set Checkbox Value" command.

                sf.ui.proTools.windows.whoseTitle.is('Bounce').first.checkBoxes.whoseTitle.is('Add MP3').first.checkboxSet({
                    targetValue: "Disable",
                });
                
                1. Wow super cool @Kitch!! Loving to see your progress.

            2. In reply tochrscheuer:
              JJuan B Caballero @Juan_B_Caballero
                2021-01-10 03:18:19.130Z

                Hello, I am interested in having an MP3 bounce command. In the end, I'm thinking of adding an "Open Session Folder" action so that my bounced files folder appears in front and it is easy to find the bounce I just did.
                The problem is that none of the Bounce to MP3 command that I found worked. All of them are sending me an error message.
                I tried with this script, assuming that all //rows are just informative. (I also tried copying the entire text, by the way) and it doesn't work. Any idea of what would it be what I'm doing wrong?
                Kind regards!

              • In reply tochrscheuer:
                Mike Wax @mikewax
                  2020-10-11 05:54:04.750Z

                  So I found this thread looking to automate my bouncing, like everyone else. And thought I would take a stab at it.

                  This is my first script, but I wanted to give thanks first to @chrscheuer because i took the script that he originally wrote at the top and used that as my building block to add on to. So many thanks!!!

                  I have different types of bounces that I need to deliver to different departments (i.e. editors want multi-channel stems, animation wants just a stereo WAV file of my full mix, etc.) So I wanted something that could be module. So this is what I did.

                  This script selects the VIDEO track, brings up the Bounce window, asks you for a file name, asks how many sources you'd like to ADD (that's important, add to the existing sources. I'm working on changing it to be add or subtract. That will be 2.0), sets all the sources to the correct stem (designated in the script), sets all the correct settings (including multi-channel wav), than asks you to choose a save destination, waits for that to close, bounces it, and then gives you an alert when the bounce is done!

                  Please feel free to use this, modify it, critique it, add on to it, anything. I'm still very beginner at scripting, so hopefully i did things correct here, but i'm totally open to any help or anything missed or could do better.

                  Hope this helps someone the way it helped me.
                  Thank you again for the help and inspiration.

                  // Activate Pro Tools
                  sf.ui.proTools.appActivate();
                  
                  // Select the VIDEO track
                  sf.ui.proTools.trackGetByName({ name: "VIDEO", makeVisible: true }).track.trackSelect();
                  
                  sf.wait({
                      intervalMs: 200,
                  });
                  
                  sf.ui.proTools.menuClick({
                      menuPath: ["Edit","Select All"],
                  });
                  
                  //Invoke the File->Bounce to->Disk... menu item
                  sf.ui.proTools.menuClick({ menuPath: ['File', 'Bounce to', 'Disk...'] });
                  
                  //Wait for the 'Bounce' dialog to appear and assign it to the bounceDlg variable
                  var bounceDlg = sf.ui.proTools.dialogWaitForManual({
                      dialogTitle: 'Bounce'
                  }).dialog;
                  
                  // Prompt for file name
                  var fileName = prompt("What would you like your File Name to be?");
                  
                  // Place file name into FILE NAME field.
                  sf.ui.proTools.windows.whoseTitle.is('Bounce').first.textFields.first.elementSetTextFieldWithAreaValue({
                      value: fileName,
                  });
                  
                  
                  
                  // CLICK TO ADD SOOURCES
                  var numOfSources = prompt("How many sources would you like to add?");
                  
                  for(var i=0; i < +numOfSources; i++) {
                      sf.ui.proTools.windows.whoseTitle.is('Bounce').first.mouseClickElement({
                          relativePosition: {"x":291,"y":51},
                      });
                  }
                  
                  sf.wait({
                      intervalMs: 500,
                  });
                  
                  // BOUNCE SOURCES
                  var bounceSource = bounceDlg.getElements("AXChildren").filter(function(e){ return e.fullRole == "AXPopUpButton" });
                  
                  var source01 = bounceSource[0];
                  var source02 = bounceSource[1];
                  var source03 = bounceSource[2];
                  var source04 = bounceSource[3];
                  
                  // Set your bounce sources here:
                  if (source01.value.value != 'output', 'MAIN OUT (Stereo) -> MAIN OUT')
                      source01.popupMenuSelect({ menuPath: ['output', 'MAIN OUT (Stereo) -> MAIN OUT'] });
                  
                  if (source02.value.value != 'bus', 'DX MIX (Stereo)')
                      source02.popupMenuSelect({ menuPath: ['bus', 'DX MIX (Stereo)'] });
                  
                  if (source03.value.value != 'MX MIX (Stereo)')
                      source03.popupMenuSelect({ menuPath: ['bus', 'MX MIX (Stereo)'] });
                  
                  if (source04.value.value != 'bus', 'SFX MIX (Stereo)')
                      source04.popupMenuSelect({ menuPath: ['bus', 'SFX MIX (Stereo)'] });
                  
                  //Special code for now (this will change and be made easier)
                  //What this does is get the Children of the bounceDialog, filter them so we only get the popupbuttons,
                  //and then slice the resulting array so then we only get the last 4.
                  //This is needed since there are no names/titles/labels on the 4 buttons used to set up file type, format, bit depth and
                  //sample rate. We take the last 4, since the bounce sources will be the first X number of popup buttons in the dialogue,
                  //but we don't know how many of those that there are.
                  var popupButtons = bounceDlg.getElements("AXChildren").filter(function(e){ return e.fullRole == "AXPopUpButton" }).slice(-5);
                  
                  //Assign the four buttons coming out of the previous instruction to individual variables
                  var fileTypeBtn = popupButtons[0];
                  var formatBtn = popupButtons[1];
                  var deliveryBtn = popupButtons[2];
                  var bitDepthBtn = popupButtons[3];
                  var sampleRateBtn = popupButtons[4];
                  
                  //If the value is not already WAV, use the popupMenuSelect action to (1. click the button, 2. select the corresponding menuPath item in the popup menu)
                  if (fileTypeBtn.value.value != 'WAV')
                      fileTypeBtn.popupMenuSelect({ menuPath: ['WAV'] });
                  
                  if (formatBtn.value.value != 'Interleaved')
                      formatBtn.popupMenuSelect({ menuPath: ['Interleaved'] });
                  
                  if (deliveryBtn.value.value != 'Single File')
                      deliveryBtn.popupMenuSelect({ menuPath: ['Single File'] });
                  
                  if (bitDepthBtn.value.value != '24 Bit')
                      bitDepthBtn.popupMenuSelect({ menuPath: ['24 Bit'] });
                  
                  if (sampleRateBtn.value.value != '48 kHz')
                      sampleRateBtn.popupMenuSelect({ menuPath: ['48 kHz'] });
                  
                  
                  // Choose a destination to save you file.
                  sf.ui.proTools.windows.whoseTitle.is('Bounce').first.buttons.whoseTitle.is('Choose...').first.elementClick();
                  
                  // Wait to pick a destination
                  sf.ui.proTools.windows.whoseTitle.is('Open').first.elementWaitFor({
                      waitType: "Disappear",
                      timeout: -1,
                  });
                  
                  
                  // BOUNCE IT!!
                  sf.ui.proTools.windows.whoseTitle.is('Bounce').first.buttons.whoseTitle.is('Bounce').first.elementClick();
                  
                  // Wait for the bounce modal to be complete. -1 doesn't timeout.
                  sf.ui.proTools.waitForNoModals({
                      timeout: -1,
                  });
                  
                  // Alert you of your bounce! And encouraging message.
                  sf.interaction.notify({
                      title: "BOUNCE COMPLETE!",
                      message: "Your bounce is ready to go! You are awesome. Keep it up!.",
                  });
                  
                  1. That's awesome, Mike! Congrats on your first script!

                    1. Mike Wax @mikewax
                        2020-10-11 20:21:54.448Z

                        Thanks man! You guys have all been a big help.

                        Here's to continued learning and many more scripts!

                      • In reply tomikewax:
                        LLlion Robertson @Llion_Robertson
                          2023-09-06 14:57:30.636Z

                          Hi everyone,
                          I'm using this script to try and automate my bounces for an UA Apollo x6 but it's getting stuck at the bounce source at line 47.

                          Here's a screenshot of the options in the Pro Tools Mix Source drop down:

                          I just keep getting an error at line 47 saying 'Could not find menu item with name 'Apollo MAIN (Stereo) -> Apollo MAIN'. I've tried gaps before the first Apollo and all permutations within the path but no luck.
                          Any ideas?

                          Thanks in advance!

                          1. @Llion_Robertson, the problem I see here is that at line 47 you're attempting to check if the Mix Source is set to a path (an array of strings), instead of a single string value—which is just the name of the source. If we rectify that, it should work.

                            Replace line 47 with the one below and give it another shot:

                            if (source01.value.value !== "Apollo MAIN (Stereo) -> Apollo MAIN")
                            
                            1. LLlion Robertson @Llion_Robertson
                                2023-09-11 10:39:03.843Z

                                Thank you Raphael :)

                          2. L
                            In reply tochrscheuer:
                            luiz ortega @luiz_ortega
                              2021-03-09 18:44:32.824Z

                              hello everyone!

                              I'm trying to use this script to bounce a mix, but I'm getting the error: "object has no method - menu/clickmenu (bounce line 2).

                              Could someone help me out?

                              Cheers!