No internet connection
  1. Home
  2. Macro and Script Help

Bounce Mix - Select Multi Mix Sources

By Nicolai Linck @Nicolai_Linck7
    2023-03-14 16:31:13.020Z

    Title

    Bounce Mix - Select Multi Mix Sources

    What do you expect to happen when you run the script/macro?

    This script opens up det Bounce window, ads 3 mix sources and selects the physical outputs: DX, FX and MX BED. It all works great.. But

    Are you seeing an error?

    What happens when you run this script?

    If multible mix sources are selected when opening the window the script will just add more to the existing count.

    Is there a way to detect the count? remove the sources in a smart way so that you dont get an error if the count is unkoown?

    How were you running this script?

    I clicked the "Run Script" or "Run Macro" button in SoundFlow

    How important is this issue to you?

    3

    Details

    {
        "inputExpected": "This script opens up det Bounce window, ads 3 mix sources and selects the physical outputs: DX, FX and MX BED. \nIt all works great.. But\n",
        "inputIsError": false,
        "inputWhatHappens": "If multible mix sources are selected when opening the window the script will just add more to the existing count. \n\nIs there a way to detect the count? remove the sources in a smart way so that you dont get an error if the count is unkoown?",
        "inputHowRun": {
            "key": "-MpfwYA4I6GGlXgvp5j1",
            "title": "I clicked the \"Run Script\" or \"Run Macro\" button in SoundFlow"
        },
        "inputImportance": 3,
        "inputTitle": "Bounce Mix - Select Multi Mix Sources"
    }

    Source

    
    sf.ui.proTools.appActivateMainWindow();
    
    sf.ui.proTools.getMenuItem('File', 'Bounce Mix...').elementClick();
    
    //Wait for 'Bounce Mix' window
        let bounceWin = sf.ui.proTools.dialogWaitForManual({
            dialogTitle: 'Bounce Mix'
        }).dialog;
    
    // CLICK TO ADD SOOURCES
    const mixSourceButtonTitle = 'DX BED (7.1.2)';
    const mixSourcePath = ["physical output", "DX BED (7.1.2)"];
    
    
    const bounceDlg = sf.ui.proTools.windows.whoseTitle.is("Bounce Mix").first;
    
    //Mix Source - Popup Menu
    if (bounceDlg.popupButtons.allItems[1].value.invalidate().value !== mixSourceButtonTitle) {
        bounceDlg.popupButtons.allItems[1].popupMenuSelect({
            menuSelector: items => items.filter(item =>
                item.path[0].endsWith(mixSourcePath[0]) &&
                item.path[1].endsWith(mixSourcePath[1]))[0]
        });
    }
    sf.ui.proTools.windows.whoseTitle.is("Bounce Mix").first.buttons.whoseTitle.is("Add row").first.mouseClickElement({
        anchor: "TopLeft",
    });
    const mixSourceButtonTitle = 'FX BED (7.1.2)';
    const mixSourcePath = ["physical output", "FX BED (7.1.2)"];
    
    
    const bounceDlg = sf.ui.proTools.windows.whoseTitle.is("Bounce Mix").first;
    
    //Mix Source - Popup Menu
    if (bounceDlg.popupButtons.allItems[2].value.invalidate().value !== mixSourceButtonTitle) {
        bounceDlg.popupButtons.allItems[2].popupMenuSelect({
            menuSelector: items => items.filter(item =>
                item.path[0].endsWith(mixSourcePath[0]) &&
                item.path[1].endsWith(mixSourcePath[1]))[0]
        });
    }
    sf.ui.proTools.windows.whoseTitle.is("Bounce Mix").first.buttons.whoseTitle.is("Add row").first.mouseClickElement({
        anchor: "TopLeft",
    });
    const mixSourceButtonTitle = 'MX BED (7.1.2)';
    const mixSourcePath = ["physical output", "MX BED (7.1.2)"];
    
    
    const bounceDlg = sf.ui.proTools.windows.whoseTitle.is("Bounce Mix").first;
    
    //Mix Source - Popup Menu
    if (bounceDlg.popupButtons.allItems[3].value.invalidate().value !== mixSourceButtonTitle) {
        bounceDlg.popupButtons.allItems[3].popupMenuSelect({
            menuSelector: items => items.filter(item =>
                item.path[0].endsWith(mixSourcePath[0]) &&
                item.path[1].endsWith(mixSourcePath[1]))[0]
        });
    }
    
    
    
    
    
    
        
    

    Links

    User UID: QO1zQljHOKXAG1PpilXlugc9h0d2

    Feedback Key: sffeedback:QO1zQljHOKXAG1PpilXlugc9h0d2:-NQVxXGIKLzqArBErbhx

    Feedback ZIP

    • 7 replies
    1. N
      Nicolai Linck @Nicolai_Linck7
        2023-03-25 08:19:19.132Z

        Anyone?

        1. I think the easiest way to do this would be to store the bounce window settings in one of the 1-5 preset buttons or or save the settings and select them from the top settings menu. Then just write a short script to select them

          1. or are you trying to add you bounce sources in addition to what may already be there?

        2. In reply toNicolai_Linck7:
          Chris Shaw @Chris_Shaw2023-03-30 21:00:22.171Z2023-04-01 01:22:49.397Z

          Try this:
          This will add/delete the number of sources needed (determined by the mixSources array) then set all of the source popups.

          To use different sources just add or remove the paths in the mixSources array.
          //CS//

          //Paths to desired sources
          const mixSources = [
              ["physical output", "DX BED (7.1.2)"],
              ["physical output", "FX BED (7.1.2)"],
              ["physical output", "MX BED (7.1.2)"],
          ];
          
          sf.ui.proTools.appActivateMainWindow();
          
          // Define Bounce Window
          const bounceWindow = sf.ui.proTools.windows.whoseTitle.is("Bounce Mix").first
          
          // Open bounce Window
          sf.ui.proTools.getMenuItem('File', 'Bounce Mix...').elementClick();
          
          // Wait for Bounce Window
          bounceWindow.elementWaitFor()
          
          // Count the number of move row buttons
          // This will determine how many sources exist in the bounce window
          let existingSources = bounceWindow.buttons.whoseTitle.is("Move row").allItems.length;
          
          // If no Move Row buttons exist then there is only one existing source
          if (existingSources == 0) existingSources = 1
          
          //Determine which button to press to add or remove sources (rows)
          const addOrRemove = existingSources < mixSources.length ? "Add " : "Remove "
          
          // Define button to press
          const addOrRemoveButton = bounceWindow.buttons.whoseTitle.is(addOrRemove + "row").first
          
          // Determine how many sources to add or delete
          // If number is negative (remove rows) then ensure resulting number is positive via Math.abs
          const addOrDeleteCount = Math.abs(mixSources.length - existingSources)
          
          // Add or remove rows
          addOrRemoveButton.mouseClickElement({
              clickCount: addOrDeleteCount
          });
          
          // Set bounce sources 
          mixSources.forEach((path, index) => {
              bounceWindow.popupButtons.allItems[index + 1].popupMenuSelect({
                  menuPath: path
              });
          })
          
          1. If this doesn't work then you'll probably have to use the menu filtering you have in your script. If that's the case, replace line 44 in my script with :

             menuSelector: items => items.filter(item =>
                        item.path[0].endsWith(mixSourcePath[0]) &&
                        item.path[1].endsWith(mixSourcePath[1]))[0]
            
          2. N
            In reply toNicolai_Linck7:
            Nicolai Linck @Nicolai_Linck7
              2023-04-24 14:31:21.540Z

              Hi Chris. I have been very busy so i haven't had time before now to try out your code. It works like a charm. Thank you!

              1. NNicolai Linck @Nicolai_Linck7
                  2025-04-28 09:01:24.811Z

                  Hi again Chris.

                  Im having issues with line 48. The script is working well for the most parts, but its throwing an error saying:

                  Could not open popup menu (Bounce Video test Copy: Line 48)
                  Popup menu was not found
                  Popup window was not found after waiting 2000 ms
                  Sometimes its stopping on the first Mix Source, sometimes almost the last.

                  The code is here:

                  //Paths to desired sources
                  const mixSources = [
                      ["bus", "2.0 Master (Stereo)"],
                      ["bus", "5.1 Master (5.1)"],
                      ["bus", "Dia Stem 2.0 (Stereo)"],
                      ["bus", "Dia Stem 5.1 (5.1)"],
                      ["bus", "FX Stem 2.0 (Stereo)"],
                      ["bus", "FX Stem 5.1 (5.1)"],
                      ["bus", "Music Stem 2.0 (Stereo)"],
                      ["bus", "Music Stem 5.1 (5.1)"],
                  ];
                  
                  sf.ui.proTools.appActivateMainWindow();
                  
                  // Define Bounce Window
                  const bounceWindow = sf.ui.proTools.windows.whoseTitle.is("Bounce Mix").first
                  
                  // Open bounce Window
                  sf.ui.proTools.getMenuItem('File', 'Bounce Mix...').elementClick();
                  
                  // Wait for Bounce Window
                  bounceWindow.elementWaitFor()
                  
                  // Count the number of move row buttons
                  // This will determine how many sources exist in the bounce window
                  let existingSources = bounceWindow.buttons.whoseTitle.is("Move row").allItems.length;
                  
                  // If no Move Row buttons exist then there is only one existing source
                  if (existingSources == 0) existingSources = 1
                  
                  //Determine which button to press to add or remove sources (rows)
                  const addOrRemove = existingSources < mixSources.length ? "Add " : "Remove "
                  
                  // Define button to press
                  const addOrRemoveButton = bounceWindow.buttons.whoseTitle.is(addOrRemove + "row").first
                  
                  // Determine how many sources to add or delete
                  // If number is negative (remove rows) then ensure resulting number is positive via Math.abs
                  const addOrDeleteCount = Math.abs(mixSources.length - existingSources)
                  
                  // Add or remove rows
                  addOrRemoveButton.mouseClickElement({
                      clickCount: addOrDeleteCount
                  });
                  
                  // Set bounce sources 
                  mixSources.forEach((path, index) => {
                      bounceWindow.popupButtons.allItems[index + 1].popupMenuSelect({
                          menuPath: path
                      });
                  })
                  
                  
                  

                  Thanks in advance!!