No internet connection
  1. Home
  2. How to

How to Create a Macro to View ONLY Midi Clips in the PT Clips Bin

By Ron Aston @Ron_Aston
    2021-09-28 23:34:41.296Z

    I'm hoping that there's a way to create a macro or script that would allow for me to quickly view JUST midi clips in the PT Clips bin. I guess I would also need another one that would switch me back to viewing all categories of clips in the Clips bin. A toogle would be nice but I'd settle for 2 separate macros.

    The reason for this is because I'm toying with the idea of using a Midi track at the top of the PT edit window and using Midi Clip Groups for cuing purposes. Having a macro that would just show me midi clips would allow me to just display these cues in the clips bin without all of the chaos of the PT clips bin and it's lack of organization. Would this be possible? Here's what I'm attempting to achieve without all of the rediculous clicking that is needed to just show midi clips and then back to the original view.

    Thanks in advance!

    • 20 replies

    There are 20 replies. Estimated reading time: 11 minutes

    1. Kitch Membery @Kitch2021-09-29 00:39:45.405Z

      Ron, mate!!

      Here is the simple way of doing it via menu selection.

      ["Audio", "Video", "Groups", "Auto-Created"].forEach(trackType => {
          sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is("Clip List").first.popupMenuSelect({
              menuPath: ["Show", trackType],
          });
      });
      

      It's not foolproof though. This will just toggle the individual menu items one by one. If I have a chance this week I'll see if I can whip something up that's a bit more robust. :-)

      Rock on!

      1. Ben Rubin @Ben_Rubin
          2022-05-11 13:48:06.149Z

          hey @kitch,

          reviving this thread as the clip bin is fairly under-scripted in SF. I'd love to be able to toggle "Full Path" on and off for example. I'm sure it's not difficult for you but it's beyond my current abilities.

          thanks!

          1. Ben Rubin @Ben_Rubin
              2022-05-11 13:53:02.903Z

              Check that. Apparently not beyond my abilities after modifying your script, @Kitch

              sf.ui.proTools.appActivateMainWindow();
              sf.ui.proTools.invalidate();
              
              ["Full Path"].forEach(trackType => {
                  sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is("Clip List").first.popupMenuSelect({
                      menuPath: ["Show", trackType],
                  });
              });
              
              

              but I'm sure you have plenty of ideas to make it better!

              b

              1. Kitch Membery @Kitch2022-05-11 19:30:18.042Z

                Nice one @Ben_Rubin,

                Here it is simplified.

                sf.ui.proTools.appActivateMainWindow();
                
                sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is("Clip List").first.popupMenuSelect({
                    menuPath: ["Show", "Full Path"],
                });
                

                You can also do this using only macros;

                • Create a new Macro.
                • Add the "Activate Apps Main Window" Macro Action and assign the Application to Pro Tools
                • Add an "Open & Select Item in Popup Menu" macro action.
                • Use the "Open & Select Item in Popup Menu" "Pick" button to select the "Clip List" popup button in Pro Tools.
                • Add the menu path for "Show", "Full Path"
                  The Macro should then look something like this;

                If you then need the Macro in script form you can click the "Convert to Script" button in the header of the Macro.

                I hope that helps.

                Rock on!

                1. Ben Rubin @Ben_Rubin
                    2022-05-11 22:59:32.319Z

                    cool thanks @kitch!

                    1. Ben Rubin @Ben_Rubin
                        2022-05-11 23:00:00.995Z

                        When is the invalidate needed?

                        1. Kitch Membery @Kitch2022-05-11 23:20:10.337Z

                          Ah yes...That's an in-depth question that I could oversimplify. So here is a post that Christian wrote that may help you.

                          1. Ben Rubin @Ben_Rubin
                              2022-05-12 03:42:12.826Z

                              I actually need a simplification from that post! I definitely learned that I've probably been over-using it so I need to understand where it is required. Maybe there's a middle-ground explanation?

                              1. Ben Rubin @Ben_Rubin
                                  2022-05-12 13:41:43.597Z

                                  I'd also love an explainer on the differences between app invalidate and mainwindow invalidate, though i suppose this will become clear once i know the main answer.

                                  1. In reply toBen_Rubin:
                                    Kitch Membery @Kitch2022-05-13 01:30:38.740Z2022-05-14 08:31:46.478Z

                                    Hi Ben,

                                    This may be an oversimplification. but essentially the invalidate() method clears the SoundFlow cache's retained information depending on its position in a line of code.

                                    The invalidate() call invalidates the node right to the left, for example...

                                    sf.ui.proTools.mainWindow.invalidate();
                                    

                                    ... invalidates the mainWindow node.

                                    So this...

                                    sf.ui.proTools.mainWindow.invalidate().transportViewCluster;
                                    

                                    ... invalidate() method invalidates the mainWindow and EVERYTHING inside the main window, including the transportViewCluster.

                                    SoundFlow does a pretty good job of invalidating without user intervention but there are some instances when invalidation is needed.

                                    When debugging an issue with a script that you feel may be to do with SoundFlow addressing old information in its cache;

                                    • Add an invalidate() as far left as possible in the line of code.
                                    • Then incrementally move it to the right till the issue surfaces again.
                                    • And finally adjust it back one more position to the left so that you are invalidating the least amount of cache information, (Note: invalidating nodes can slow down scripts because the invalidated node's information and everything downstream of it needs to be re-collected.)

                                    I'll have a think as to a good example to illustrate where the invalidate() method would fix an issue in a script and get back to you.

                                    I hope that helps :-)
                                    Rock on!

                                    THIS POST HAS BEEN UPDATED 05/14/22

                                    1. Ben Rubin @Ben_Rubin
                                        2022-05-13 01:34:50.035Z

                                        Thanks @Kitch! this definitely helps. and yes please, examples will help me even more. i fear i've been over-invalidating!

                                        1. Kitch Membery @Kitch2022-05-13 01:36:01.888Z

                                          Glad that helps... Will keep you posted on a clear example for sure. :-)

                                          1. In reply toBen_Rubin:
                                            Kitch Membery @Kitch2022-05-13 02:12:04.639Z

                                            OK here is a good simple example of how the invalidate() method works;

                                            Run the following script which should logs the file name and extension of the current Pro Tools session;

                                            sf.ui.proTools.appActivateMainWindow();
                                            
                                            //Get the current session path
                                            const sessionPath = sf.ui.proTools.mainWindow.sessionPath;
                                            //Get the current session file name
                                            const sessionFileName = sessionPath.split('/').slice(-1)[0];
                                            
                                            log(sessionFileName);
                                            

                                            This should log the current Pro Tools session name that is collected from the main window of Pro Tools as seen here;

                                            The log will say;

                                            [LOG] My Session Name.ptx
                                            

                                            Which is correct and what we expect :-)

                                            Now, to throw a spanner in the works, let's save the session, giving it a new name... for example, save the session as "New and Improved Session".

                                            The Pro Tools main window will now show this new name;

                                            Now run the script again and you will see that the SoundFlow Cache has retained the information from the previous run of the script. So the result is again;

                                            [LOG] My Session Name.ptx
                                            

                                            ... which is obviously incorrect.

                                            If we change the script by adding an invalidate() method after the mainWindow node. like this;

                                            sf.ui.proTools.appActivateMainWindow();
                                            
                                            //Get the current session path
                                            const sessionPath = sf.ui.proTools.mainWindow.invalidate().sessionPath;
                                            //Get the current session file name
                                            const sessionFileName = sessionPath.split('/').slice(-1)[0];
                                            
                                            log(sessionFileName);
                                            

                                            ... and run the script again, the script logs the updated session name from the Pro Tools main window;

                                            [LOG] New and Improved Session.ptx
                                            

                                            I hope that clarifies invalidation for you. :-)

                                            Rock on!

                                            1. Invalidating the main window is also necessary after your script adds or deletes a track in the main window.

                                              1. Yes! This is the most common reason to invalidate :)

                                                1. Ben Rubin @Ben_Rubin
                                                    2022-05-14 19:57:16.523Z

                                                    All helpful info for my novice coding. Any other major examples like that?

                                                    Thanks, @chrscheuer @Chris_Shaw.

                                                    1. You'll also need to invalidate dialog windows if you switch tabs, as that means UI elements get re-generated.

                                                      1. Ben Rubin @Ben_Rubin
                                                          2022-05-16 15:46:58.761Z

                                                          what's a tab in this case??

                                                          1. A good example for tabs is the PT prefs window, the tabs run along the top of the window (Display, mixing, etc)

                                                            1. Ben Rubin @Ben_Rubin
                                                                2022-05-16 17:23:23.484Z

                                                                got it, thanks