No internet connection
  1. Home
  2. Script Sharing

Auto_Align Post Macro by @Owen_Granich_Young

By Jason Freeman @Jason_Freeman
    2024-04-05 18:01:25.248Z

    @Owen_Granich_Young
    Per our convo on the sound radix forum, could you please post your auto-align post reference track macro, please and thank you!!

    • 5 replies
    1. O

      You bet Jason!

      Here's the one for ADR, highlight all the tracks and then press the button and it selects all the even tracks and processes them to the track above them. (Currently Y on my keyboard that's how much I'm using it, lol) This also works for a single pair if you highlight two tracks it will auto align the bottom one to the top one.

      let win = sf.ui.proTools.firstAudioSuiteWindow
      let ogTimelineSeleciton = sf.ui.proTools.selectionGet();
      
      function setupAndRestore(callback) {
          sf.ui.proTools.appActivateMainWindow();
      
          const videoWinowMenuItem = sf.ui.proTools.getMenuItem('Window', 'Video');
      
          const initialViews = {
              isVideoWinOpen: videoWinowMenuItem.getString('AXMenuItemMarkChar') === ('-') || videoWinowMenuItem.isMenuChecked,
              isFloatingWindowsEnabled: sf.ui.proTools.getMenuItem('Window', 'Hide All Floating Windows').isMenuChecked,
          }
      
          const { isVideoWinOpen, isFloatingWindowsEnabled } = initialViews;
      
          if (isVideoWinOpen) { sf.ui.proTools.menuClick({ menuPath: ['Window', 'Video'], }); }
          if (!isFloatingWindowsEnabled) { sf.ui.proTools.menuClick({ menuPath: ['Window', 'Hide All Floating Windows'], }); }
      
          try {
      
              callback();
      
          } finally {
      
              const modifiedViews = {
                  isVideoWinOpen: (videoWinowMenuItem.getString('AXMenuItemMarkChar') === ('-') || videoWinowMenuItem.isMenuChecked) !== initialViews.isVideoWinOpen,
                  isFloatingWindowsEnabled: sf.ui.proTools.getMenuItem('Window', 'Hide All Floating Windows').isMenuChecked !== initialViews.isFloatingWindowsEnabled,
              }
      
              const { isVideoWinOpen, isFloatingWindowsEnabled } = modifiedViews;
      
              if (isVideoWinOpen) { sf.ui.proTools.menuClick({ menuPath: ['Window', 'Video'], }); }
              if (isFloatingWindowsEnabled) { sf.ui.proTools.menuClick({ menuPath: ['Window', 'Hide All Floating Windows'], }); }
          }
      }
      
      function getBeforeSelectedTrackName() {
      
          const visibleTrackNames = sf.ui.proTools.visibleTrackNames
      
          const selectedTrackName = sf.ui.proTools.selectedTrackNames[0]
      
          const selectedTrackIndex = visibleTrackNames.indexOf(selectedTrackName)
      
          return visibleTrackNames[selectedTrackIndex - 1]
      
      }
      
      function doForAllSelectedTracks(action) {
          var originallySelectedTrackNames = sf.ui.proTools.selectedTrackNames;
      
          try {
              sf.ui.proTools.selectedTrackHeaders.forEach(track => {
                  track.trackSelect();
                  action(track);
              });
          }
          finally {
              sf.ui.proTools.trackSelectByName({ names: originallySelectedTrackNames });
          }
      }
      
      function autoEachSet() {
          const selectedTrackName = sf.ui.proTools.selectedTrackNames[0]
          const sideChainButton = win.popupButtons.allItems[4]
      
      
          if (sideChainButton.exists && selectedTrackName) {
              sideChainButton.popupMenuSelect({
                  menuPath: [getBeforeSelectedTrackName()],
              });
          }
      
          win.audioSuiteRender();
      
          sf.ui.proTools.waitForNoModals();
      
          sf.ui.proTools.selectionSetTimecode({
              selectionStart: ogTimelineSeleciton.selectionStart,
              selectionLength: ogTimelineSeleciton.selectionLength,
              selectionEnd: ogTimelineSeleciton.selectionEnd
      
          })
      }
      
      function main() {
          setupAndRestore(() => {
              sf.ui.proTools.appActivateMainWindow();
              sf.ui.proTools.invalidate();
              const aApostIsOpen = sf.ui.proTools.windows.whoseTitle.is("Audio Suite: Auto-Align Post").first.exists
      
              const selectedTrackNames = sf.ui.proTools.selectedTrackNames;
              const everyOtherTrack = selectedTrackNames.filter((_, index) => index % 2 === 1);
      
              sf.ui.proTools.trackSelectByName({ names: everyOtherTrack, deselectOthers: true });
      
      
              if (aApostIsOpen) {
                  sf.ui.proTools.windows.whoseTitle.is("Audio Suite: Auto-Align Post").first.elementRaise();
              } else {
                  sf.ui.proTools.audioSuiteOpenPlugin({
                      category: "Other",
                      name: "Auto-Align Post",
                  });
              }
      
              win.audioSuiteSetOptions({
                  processingInputMode: 'ClipByClip',
                  processingOutputMode: `CreateIndividualFiles`,
              });
      
              doForAllSelectedTracks(autoEachSet)
      
              if (!aApostIsOpen) {
                  win.windowClose({}, `Could not find Audiosuite Window`);
              }
          });
      }
      
      main();
      

      And this one select the tracks you want auto aligned (say a few character's lav mics) and they will all align to the track ABOVE the ones selected. It's a little funky that this one you don't select the guide track as the top most, but I think I'm ok with it.

      function getBeforeSelectedTrackName() {
      
          const visibleTrackNames = sf.ui.proTools.visibleTrackNames
      
          const selectedTrackName = sf.ui.proTools.selectedTrackNames[0]
      
          const selectedTrackIndex = visibleTrackNames.indexOf(selectedTrackName)
      
          return visibleTrackNames[selectedTrackIndex - 1]
      
      }
      
      function main() {
          sf.ui.proTools.appActivateMainWindow();
          sf.ui.proTools.invalidate();
          const aApostIsOpen = sf.ui.proTools.windows.whoseTitle.is("Audio Suite: Auto-Align Post").first.exists
      
          if (aApostIsOpen) {
              sf.ui.proTools.windows.whoseTitle.is("Audio Suite: Auto-Align Post").first.elementRaise();
          } else {
              sf.ui.proTools.audioSuiteOpenPlugin({
                  category: "Other",
                  name: "Auto-Align Post",
              });
          }
      
          let win = sf.ui.proTools.firstAudioSuiteWindow
      
      
          win.audioSuiteSetOptions({
              processingInputMode: 'ClipByClip',
              processingOutputMode: `CreateIndividualFiles`,
          });
      
          const selectedTrackName = sf.ui.proTools.selectedTrackNames[0]
          const sideChainButton = win.popupButtons.allItems[4]
      
          if (sideChainButton.exists && selectedTrackName) {
              sideChainButton.popupMenuSelect({
                  menuPath: [getBeforeSelectedTrackName()],
              });
          }
      
          win.audioSuiteRender();
      
          sf.ui.proTools.waitForNoModals();
      
          if(!aApostIsOpen){
          win.windowClose({}, `Could not find Audiosuite Window`);
          }
      }
      
      main();
      

      Happy Aligning
      Owen

      1. J
        In reply toJason_Freeman:
        Jason Freeman @Jason_Freeman
          2024-04-05 18:37:11.088Z

          Amazing! Im going to give these a try right now.

          1. JJason Freeman @Jason_Freeman
              2024-04-05 19:24:29.316Z

              OMG! This is EXACTLY what I have been looking for! You just saved me countless amounts of clicking and moving clips around. THANK YOU!

            • D
              In reply toJason_Freeman:
              danielkassulke @danielkassulke
                2024-04-06 08:10:14.781Z

                @Owen_Granich_Young this code absolutely rips. Thanks!

                1. Just cobbled together from @samuel_henriques and @Kitch code. @Brian_Armstrong got me building it in the first place. I’ve actually never owned auto align without it, I can’t imagine using it with out lol. So many clicks.

                  Bests
                  Owen