No internet connection
  1. Home
  2. How to

Repeat Process Until End Of Clip

By Ben Zenium @Ben_Zenium
    2020-10-01 10:30:42.045Z

    Hi guys,

    Firstly, thanks again to Christian and everyone else on the forum for all your help, Im absolutely loving the community here.

    Does anybody know if theres a way to repeat a macro chain, until the end of a clip in ProTools?
    For instance, I'd like to do certain actions at marker points, but is there a way to repeat those events at marker points, until the end of the clip?

    I have it set up at the moment so it's a repeat process for a set number of repetitions, but just wondering if I could just point it at a clip and say 'off you go' until it gets to the end of that clip

    Solved in post #6, click to view
    • 11 replies
    1. Hi Ben,

      Yes, you can do that - but it's easier to help with the specific script/actions you're taking. Please share the script you have currently, and then we can add the requested behavior to it.

      1. BBen Zenium @Ben_Zenium
          2020-10-02 08:41:01.340Z

          Ah yes sorry, I was a bit cryptic in that last post. It's a super simple script of just going from marker to the next marker, and separating the audio at th emarker point. Currently it does it something like 12 times but I'd like it just to run until the end of the clip and then stop.

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 2,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          sf.ui.proTools.memoryLocationsGotoDelta({
          delta: 1,
          });

          sf.ui.proTools.menuClick({
          menuPath: ["Edit","Separate Clip","At Selection"],
          });

          1. Hi Ben,

            Thanks - this makes sense. Are you working in Timecode?

            1. BBen Zenium @Ben_Zenium
                2020-10-02 10:49:33.979Z

                Hi Christian. I am indeed!

                1. In reply tochrscheuer:
                  Christian Scheuer @chrscheuer2020-10-02 10:53:06.014Z2020-10-02 11:44:00.997Z

                  If you're using Timecode, then the following should work:

                  
                  //Store original selection
                  let originalSelection = sf.ui.proTools.selectionGet();
                  let originalSelectionSamples = sf.ui.proTools.selectionGetInSamples();
                  
                  try {
                      //Collapse selection to the left hand side
                      sf.ui.proTools.selectionSet({
                          selectionStart: originalSelection.selectionStart,
                          selectionEnd: originalSelection.selectionStart,
                      });
                  
                      //Perform an endless loop
                      while (true) {
                  
                          //Go to the next memory location
                          let goRes = sf.ui.proTools.memoryLocationsGotoDelta({
                              delta: 1,
                              onError: 'Continue',
                          });
                  
                          //If we didn't find a next memory location, just abort the loop
                          if (!goRes.success)
                              break;
                  
                          //Retrieve the selection at this point
                          let newSelection = sf.ui.proTools.selectionGet();
                  
                          //If we're now further to the right than the original selection,
                          //break the loop
                          if (newSelection.selectionStart > originalSelection.selectionEnd)
                              break;
                  
                          //Otherwise, click Separate Clip At Selection, and continue the loop
                          //also - if for some reason we're in between clips we're allowing the menu click to fail silently
                          sf.ui.proTools.menuClick({
                              menuPath: ["Edit", "Separate Clip", "At Selection"],
                              onError: 'Continue',
                          });
                  
                          //Continue the loop
                      }
                  } finally {
                      //Finally, regardless of any error occurring in the previous code,
                      //restore the original selection
                      sf.ui.proTools.selectionSetInSamples({
                          selectionStart: originalSelectionSamples.selectionStart,
                          selectionEnd: originalSelectionSamples.selectionEnd,
                      });
                  }
                  

                  I'll be including this command in an upcoming version of the "Pro Tools Utilities" package :)

                  ReplySolution
                  1. BBen Zenium @Ben_Zenium
                      2020-10-02 11:00:30.766Z

                      Hey Christian, thanks so much for this. The script appears to jump to the next marker and then back to where the playhead is, with no separation either.

                      1. Hi Ben,

                        Here's how it looks on my end:
                        In the video, first I'm manually playing back in real-time to add markers.
                        Then I select the clip and run the script.

                        Can you see anything you're doing differently?

                        1. BBen Zenium @Ben_Zenium
                            2020-10-02 11:41:23.652Z

                            Ah it seems to be working now!! This is amazing! Thank you Christian!! Was this something you were working on anyway or just from this thread?

                            1. Just from this thread :) Awesome that it's working for you!

                              1. I've shared this now in the Pro Tools Utilities package, so if you use it from there you'll get any updates we make to it as well.

                                1. In reply tochrscheuer:
                                  BBen Zenium @Ben_Zenium
                                    2020-10-02 11:45:11.549Z

                                    Amazing work man, thank you so much!