No internet connection
  1. Home
  2. How to

Bypass insert without toggling

By Les Cooper @Les_Cooper
    2024-09-25 12:29:19.054Z

    Hello, I'm hoping for some help. Many thanks for considering my request.

    I want to bypass an insert on my 'Master' track. In this case, a toggle insert doesn't work, as I need separate buttons.

    Script 1 - Bypass insert 10 on my 'Master' track
    Script 2 - Enable insert 10 on my 'Master' track

    • 3 replies
    1. Chris Shaw @Chris_Shaw2024-09-25 21:01:49.978Z2024-09-26 16:35:20.748Z

      You can use this script to do what you want.
      Create two scripts (one for Bypass and the other for Active) and change the the first three constants in each script to the values / state you want.
      Unfortunately SF cannot bypass an insert unless it is visible in the edit window so this script will ensure the track is scrolled into view, bypass/activate the insert, and then scroll the edit window back to its original position when done.

      IMPORTANT: The insert view (a-e or f-j) must be visible or the script will throw an error:

      const trackName = "---Master---"
      let insertNumber = 1;
      
      /** @constant {"Active" | "Bypassed"} */
      let desiredState = "Active"
      
      
      function csScrollToTrack(trackNames) {
          sf.ui.proTools.appActivate()
          const menuClickScrollToTrack = () => sf.ui.proTools.menuClick({ menuPath: ['Track', 'Scroll to Track...'] })
          var confirmationDialogWin = sf.ui.proTools.confirmationDialog;
          var scrollTrack = (typeof trackNames == "object") ? trackNames[0] : trackNames;
      
          try {
              menuClickScrollToTrack();
      
              confirmationDialogWin.elementWaitFor({ timeout: 100 });
      
          } catch (err) {
              sf.keyboard.press({ keys: "n", repetitions: 2, fast: true });
      
              menuClickScrollToTrack();
      
              confirmationDialogWin.elementWaitFor({}, `Could not find Scroll to track Dialog`);
          }
      
          confirmationDialogWin.textFields.first.elementSetTextFieldWithAreaValue({
              value: scrollTrack,
              useMouseKeyboard: true
          });
      
          confirmationDialogWin.buttons.whoseTitle.is('OK').first.elementClick();
      
          confirmationDialogWin.elementWaitFor({ waitType: 'Disappear' });
      }
      
      function determineTopMostEditTrack() {
      
          sf.ui.proTools.invalidate();
          const editTimeLineTopY = sf.ui.proTools.mainWindow.timelineFocusButton.frame.y;
          const topTrack = sf.ui.proTools.visibleTrackHeaders.filter(h => h.frame.y >= editTimeLineTopY)[0];
      
          const topTrackName = topTrack.normalizedTrackName;
      
          return topTrackName;
      };
      
      
      /////////////////////
      ////// M A I N //////
      /////////////////////
      
      sf.ui.proTools.appActivateMainWindow();
      sf.ui.proTools.mainWindow.invalidate();
      
      const masterTrack = sf.ui.proTools.trackGetByName({ name: trackName }).track;
      
      let isInsertBypassed = masterTrack.insertSelectorButtons[insertNumber - 1].value.invalidate().value.includes("bypassed");
      let insertName = masterTrack.insertButtons[insertNumber - 1].value.invalidate().value;
      
      if ((!isInsertBypassed && desiredState == "Bypassed") || (isInsertBypassed && desiredState !== "Bypassed")) {
          const topEditTrack = determineTopMostEditTrack()
      
          masterTrack.trackScrollToView();
      
          const newTopEditTrack = determineTopMostEditTrack();
      
          masterTrack.trackInsertToggleBypass({
              insertNumber: insertNumber,
          });
      
          if (topEditTrack !== newTopEditTrack) csScrollToTrack(topEditTrack);
      }
      
      sf.interaction.notify({
          title: `${trackName} | Insert ${insertNumber}`,
          message: `${insertName}: ${desiredState}`
      })
      
      1. L
        In reply toLes_Cooper:
        Les Cooper @Les_Cooper
          2024-09-26 11:17:45.038Z

          This is great, thanks SO much!

          1. @Les_Cooper,

            I discovered a bug - if the plugin that is being bypassed / activated is open the script wouldn't work.
            I also added a check to determine if it is necessary to scroll the edit window when the script finishes.

            The code above is the new edited version.