No internet connection
  1. Home
  2. How to

Waiting For Rendering

By Win Winstanley @Win_Winstanley
    2021-02-11 17:38:36.510Z

    Hi,

    I am writing a Macro that incorporates rendering an Audio Suite plugin and the renames the new rendered file with a prescibed suffix.
    Is there a specific command to wait for plugins to render that I am missing? I have tried all of the available 'wait' commands I can see but to no avail.

    Best,
    Win

    • 16 replies

    There are 16 replies. Estimated reading time: 17 minutes

    1. samuel henriques @samuel_henriques
        2021-02-11 19:10:18.256Z

        hello @Win_Winstanley,

        I'm using this command and it waits.
        Hope it works for you

        sf.ui.proTools.getAudioSuiteWindow('RX 8 De-click').audioSuiteRender();
        
        1. Yes, exactly, that's the way to go.

          See here for a complete script - there's a lot of examples on the forum, so you can search for audioSuiteRender:

          1. There's also quite a few packages on the Store with template scripts that makes this process even easier to set up.

            See for example my Pro Tools AudioSuite package:
            https://soundflow.org/store/pro-tools-audiosuite

        2. In reply toWin_Winstanley:
          Win Winstanley @Win_Winstanley
            2021-02-12 11:50:46.711Z

            Thank you both. Very much appreciated.

            Not there yet tho...
            I have been working with Macros as my script/code knowledge is minimal. When converting the Macros to Script I am finding that they then do not not work. Certain "Wait" commands for example seem to not translate. Is there a simple solution or do I need to learn more about Scripting in order to de-bug?

            1. That's hard to answer as a general question. If you're having trouble with a script, always try to follow these steps:

              • At a minimum, copy/paste the script so we can see what's going on
              • Tell us what's "not working". Specifically, what steps did you follow, what did you hope to happen, and what actually happened.

              Please see this link for how to best get help with SoundFlow, it explains in more detail how you make it easier for us to help you.

              1. Please also know, that we in SoundFlow generally don't use "Wait" commands with statically set intervals - for example "wait 2 seconds" etc. Instead, we wait for the actual operations that you're waiting on, to occur.

                I highly recommend watching the UI automation tutorials here to get a sense of what I'm talking about:

            2. In reply toWin_Winstanley:
              Win Winstanley @Win_Winstanley
                2021-02-13 13:05:14.693Z

                Hey,

                Thank you Christian. (It would appear my Forum Ettiquette is also on the poor side!)
                I will watch the video tutorials over the weekend and get back to you with more error detail and a copy of the script once I am back at the studio.

                1. In reply toWin_Winstanley:
                  Win Winstanley @Win_Winstanley
                    2021-02-17 08:56:53.375Z2021-02-17 09:04:07.084Z

                    Hi all,

                    Apologoes for the delay in getting back to you - work schedule is nuts atm.
                    The links to the recommended videos appear non-active in the forum browser. I am keen to view them still, could you possible re-direct me to them via another route?

                    To the script...

                    • The purpose of the script is to;
                    • Take the freshly printed stereo mix.
                    • Re-label the file with the project name by instigating a session Save As, copying the text and using the ESC command.
                    • Duplicate to a new playlist.
                    • Copy the reference limiter plugin settings from my monitor return channel and apply via pasting the settings to an Audio Suite instance of the plugin.
                    • Render.
                    • Rename with a prescribed text suffix.
                    • Close window all floating windows.

                    As a Macro this all works well up to the commands after Render. During trialling the Macro I used very small audio clips which enabled the entire Macro to run successfully but when applied to a genuine '"song" lengthed audio file I was unable to instruct a suitable or effective "wait" command in order to compensate for the fairly slow, hi-resolution render and the renaming element subsequently fails. This prompted my first email request.
                    After converting to Script and attempting to incorporate the suggestions from the replies I recieved I am finding that the Script fails earlier on. I would be extremely greatful for any assistance in coding corrections, so gratitudes in advance and again any apologies for any unknowing forum decorum breaches.

                    NB: the Script posted is the unammended covertion from the Macro.

                    Very best,
                    Win

                    The Script:

                    `sf.ui.proTools.menuClick({
                    menuPath: ["File","Save As..."],
                    });

                    sf.keyboard.press({
                    keys: "cmd+c, escape",
                    });

                    sf.ui.proTools.menuClick({
                    menuPath: ["Clip","Rename..."],
                    });

                    sf.keyboard.press({
                    keys: "cmd+v, return",
                    });

                    sf.ui.proTools.waitForNoModals();

                    sf.keyboard.press({
                    keys: "shift+down, shift+semicolon, ctrl+alt+v, p",
                    });

                    sf.ui.proTools.waitForNoModals();

                    const window = sf.ui.proTools.trackGetByName({ name: "MONITOR", makeVisible: true }).track.trackInsertToggleShow().window;

                    window.elementWaitFor();

                    sf.keyboard.press({
                    keys: "cmd+shift+c",
                    });

                    sf.ui.proTools.audioSuiteOpenPlugin({
                    category: "Dynamics",
                    name: "FabFilter Pro-L 2",
                    });

                    sf.ui.proTools.firstAudioSuiteWindow.elementWaitFor();

                    sf.keyboard.press({
                    keys: "cmd+shift+v",
                    });

                    sf.ui.proTools.audioSuiteRenderCurrent();

                    sf.ui.proTools.viewCloseFloatingWindows();`

                    1. Hi @Win_Winstanley,

                      You may have to watch these videos in your regular browser. They're just links to Youtube, so they should work in all browsers. You can always access the forum here from any normal browser:
                      SoundFlow Forum

                      Please check this tutorial for how to quote code in the SoundFlow forum, so that it displays in a readable format:

                      Your code/macro currently uses the Clipboard and Save As dialog, which isn't needed if you write it as a script, as you have access to the Session Name through code like this - no need to open Save As - and no need to use the Clipboard:

                      var sessionName = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
                      

                      In terms of renaming clips, instead of using Keyboard Automation, use something like the renameClip function from here:

                      In terms of waiting for the render, you may find more inspiration here:

                      1. Win Winstanley @Win_Winstanley
                          2021-02-24 09:29:16.056Z

                          Hi again,

                          Apologies for drawing this out so. Just so busy at the moment.

                          Thanks for the advise so far. I can see that there are more effective ways to command actions in script and I am beginning to follow the principles. A little way to go yet tho.
                          May I ask a favour in the interim in order to get this particular script working for me as it will be an enormous workflow time-saver;
                          **could I ask you to give me a/the script line/s that would copy the Project's name to the clipboard and then paste it to the RenameClip script? **
                          I am not quite understanding the sequencing of these events or how to write/code it yet.

                          Again, thanks in advance.
                          Win

                          1. This should provide a starting point. This code renames the currently selected clip and prefixes it with the session's name.

                            function renameClip(callback) {
                                //Make sure Pro Tools Edit Window is active
                                sf.ui.proTools.appActivateMainWindow();
                            
                                //Make sure we have no search in Clips list - if we had, Clip Rename won't work (Pro Tools bug)
                                sf.keyboard.press({ keys: 'cmd+shift+d' });
                            
                                //Clip Clip->Rename...
                                sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
                            
                                //Wait for 'Name' dialog to come up, assign the dialog to dlg variable
                                var dlg = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({}, 'Could not find "Name" dialog').element;
                            
                                //Find the first text field
                                var textField = dlg.groups.whoseTitle.is('Name').first.textFields.first;
                            
                                //Get the current Name
                                var currentName = textField.value.value;
                            
                                //Make a variable with the new name, based on the old one by calling the callback function provided in the 1st argument
                                var newName = callback(currentName);
                            
                                //Set the value of the textField
                                textField.elementSetTextFieldWithAreaValue({ value: newName });
                            
                                //Press OK
                                dlg.buttons.whoseTitle.is('OK').first.elementClick();
                            
                                //Wait for the dialog to close
                                dlg.elementWaitFor({ waitForNoElement: true });
                            }
                            
                            //Put the session's name into a variable
                            var sessionName = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
                            
                            //Rename clip with sessionName suffix, then the old name
                            renameClip(oldName => `${sessionName} - ${oldName}`);
                            
                            1. Win Winstanley @Win_Winstanley
                                2021-02-24 12:55:25.014Z

                                Thank you so much. Seeing it has helped make sense of things.

                                Very best,
                                Win

                        • In reply toWin_Winstanley:
                          Win Winstanley @Win_Winstanley
                            2021-02-25 08:35:14.434Z

                            Thanks again for this, The descripion lines are really helping to clarify the procedure.
                            Could I chance one more imposition just to make this code perfect for me?

                            renameClip(oldName => `${sessionName} - ${oldName}`);

                            How would one change this last line which pastes the oldName suffix with a prescribed suffix of "_REFLIM" for example?
                            I do appreciate that this is potentially pushing my luck but I am super grateful.
                            Best,
                            Win

                            1. Win Winstanley @Win_Winstanley
                                2021-03-03 14:17:28.898Z

                                Me again...!

                                Is anyone able to help me with this?

                                renameClip(oldName => `${sessionName} - ${oldName}`);

                                How would one change this last line which pastes the oldName suffix with a prescribed suffix of "_REFLIM" for example?

                                I can appreciate that there is a lot going on behind the scenes getting the update ready, but I really am stumped...

                                Many thanks.

                                1. Raphael Sepulveda @raphaelsepulveda2021-03-03 22:21:34.416Z2021-03-04 16:23:10.733Z

                                  Hello, Win!

                                  The simpliest way to add a suffix here would be to just add it at the end, like so:

                                  renameClip(oldName => `${sessionName} - ${oldName}_REFLIM`);
                                  

                                  The way I would do it though, would be storing the suffix in its own variable—which is the same way sessionName is being handled. Like so:

                                  //Put the session's name into a variable
                                  var sessionName = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
                                  
                                  // Add a suffix here
                                  var suffix = 'REFLIM';
                                  
                                  //Rename clip with sessionName prefix, old name and a suffix
                                  renameClip(oldName => `${sessionName} - ${oldName}_${suffix}`);
                                  

                                  Hope that helps!

                              • In reply toWin_Winstanley:
                                Win Winstanley @Win_Winstanley
                                  2021-03-04 08:44:51.079Z

                                  Absolute legend!!!

                                  Thank you Raphael.