No internet connection
  1. Home
  2. How to

Script to Replace Guardian Angel

By Jascha Viehl @Jascha_Viehl
    2020-11-11 14:53:49.784Z

    Hi,

    I was trying to replicate the behavior of "The Guardian Angel for Pro Tools".
    Using the Eucon commands on my artist control I still depend on this safety net.
    I know that with SoundFlow commands this is a non-issue.

    I figured out it should be a runForever Script.
    And that it should look ("wait") for the confirmation dialogue to appear.
    And only if the text contains "length of selection" would confirm the dialogue.

    Is first.elementWairForthe right way?
    This is what I've got, but it does nothing:

    
    function main() {
        try {
            if (sf.ui.proTools.confirmationDialog.children.whoseRole.is("AXStaticText").whoseValue.contains('length of the selection').first.elementWaitFor({
                pollingInterval: 300,
                timeout: 3000,
            })) {
                sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('OK').first.elementClick();
            }
    
    
            function runForever(guardianAngel, action, interval, timeout) {
                var now = (new Date).valueOf();
                if (now - globalState[guardianAngel] < timeout) throw 0; //Exit if we were invoked again inside the timeout
    
                globalState[guardianAngel] = now;
                sf.engine.runInBackground(function () {
                    try {
                        while (true) {
                            sf.engine.checkForCancellation();
                            globalState[guardianAngel] = (new Date).valueOf();
    
                            action();
    
                            sf.wait({ intervalMs: interval, executionMode: 'Background' });
                        }
                    } finally {
                        globalState[guardianAngel] = null;
                    }
                });
            }
    
            runForever("guardianAngel", main, 500, 5000);
    
    
    
    Solved in post #7, click to view
    • 7 replies
    1. Hi Jascha

      There's no need to replicate Guardian Angel in SoundFlow, since SoundFlow already has built-in support for writing automation in a safe way.

      See more here:

      1. JJascha Viehl @Jascha_Viehl
          2020-11-11 17:31:34.126Z

          Hi Christian,

          I know (searched for it here of course) but I'm using (and want to use) SoundFlow on a Stream Deck XL mostly for editing commands and AudioSuites. Things that I cannot do on the Artist Control.
          My automation commands, (Preview, Write to Selection, Suspend Preview, Trim...) are on softkeys on my Artist Control and therefore triggered via Eucon.
          I would like to use the perfectly fine softkeys on the Artist Control for that. And still have the guardian functionality.

          1. Ok. Can you set up your softkey to trigger a keyboard shortcut instead?
            I'm asking since you'd get a much more stable and CPU-friendly solution this way rather than trying to have a runForever script do it for you.
            We generally advise against using runForever scripts unless absolutely necessary for the implementation.

            1. JJascha Viehl @Jascha_Viehl
                2020-11-11 18:22:49.607Z2020-11-28 01:40:26.582Z

                I think the keypress would not work, since it doesn't readout which confirmation dialog to suppress (press enter) and which not.

                This is one of the cases where I would say the runForever script is absolutely necessary. :)

                Isn't Guardian Angel itself a runForver script in AppleScript?

                1. Hi Jascha,

                  SoundFlow takes care of knowing which confirmation dialogs to cancel or not. As I mentioned, this workflow is fully supported in SoundFlow.

                  The easiest way to get access to that, instead of starting from scratch and writing your own, is to just have your softkey simulate a keypress that uses the built-in SoundFlow commands "Write Automation to Selection (+ Confirmation Dialog)". That command already ensures that only safe writes will dismiss the warning dialog, and unsafe writes (to the whole session) will let the dialog stay open to allow you to know you should undo.

                  1. So in other words, you'd set up a keyboard trigger on this command in the SoundFlow -> Pro Tools -> Automation Window folder:

                    Now you can always access this from your keyboard. It takes care of knowing to automatically close the warning popup if you did a safe write - and keeps it open if it was unsafe.

                    Since you prefer running this from your Artist Control, set up your Artist Control to simulate the keypress that you used for the keyboard trigger. That way, your Artist Control gets direct access to the SoundFlow command, and it should work directly.

                    ReplySolution
                    1. JJascha Viehl @Jascha_Viehl
                        2020-11-11 19:33:26.775Z2020-11-28 01:41:02.546Z

                        Now I got it. :)

                        Only disadvantage: I take my continuously developing EuCon user set with me to mixing studios, which might not all have SoundFlow.
                        Then I need to change this EuCon sofkey in preparation.

                        I set it up and it works really great and fast.