No internet connection
  1. Home
  2. How to

Running multiple Macros automatically

By Steve Dawson @Steve_Dawson
    2022-09-04 22:15:20.308Z

    I created a fairly complex set of macros to do some specific things to my sessions. There are about 9 or 10 macros and scripts, all which get the job done. What I'd like to do is have them all run, one after the other so I can just leave the studio and come back when it's finished. Is there a way to set that up, or would I need to take all those commands and put them into one huge macro? Right now I have them spread across 9 buttons on a stream deck, and if I press one at a time, each one seems to now work. But I have to sit here and press 9 buttons to get it done. Thanks for any help!

    • 10 replies
    1. You can create a macro that runs your macros / scripts one after the other.
      Create a "Run Command" macro action for each macro / script you need to run.

      This is what the run command macro action looks like:

      To get the command id select the macro / script in the editor, go to the SF "Command" menu and select Copy Command ID and past it into the command ID field in the macro.
      (Do not select "Copy Command ID Local to Package")


      1. In reply toSteve_Dawson⬆:
        Kitch Membery @Kitch2022-09-05 23:35:59.760Z

        Hi @Steve_Dawson,

        @Chris_Shaw's method will work, however, there is a simple solution for what you are trying to achieve.

        You can simply create a new macro and add the multiple macros as Actions to that macro.

        You can add the macros to this master macro in one of two ways.

        Pinning the Master Macro
        If any of the multiple macros you want to run reside in other packages or folders, you can either pin the master macro using the "Pin" button in the top left corner of the macro editor, then navigate to where the macros reside and drag them onto the master macro. (Note: Remember to unpin the macro when you are done adding the macros).

        Add Action Button
        You can also just add your macros to the master macro by using the "+Add Action" button in the master macro's macro editor.

        So it will then look like something like this;

        Then all you have to do is assign a trigger to the master macro to run the full workflow :-)

        If any of this is not clear let me know and I'll make a video demonstrating the process.

        Rock on.

        1. Of course!
          šŸ¤¦ā€ā™‚ļø

          1. In reply toKitch⬆:
            Nnick krill @nick_krill
              2022-09-16 00:53:53.864Z

              Hiya!

              @Kitch, using this method, is there a way to make an if-then statement between the different macro building blocks?

              I'm thinking of this in a scenario where maybe in a Master Macro, one session needs to do Macro 2 but another session might need to skip it.

              I came across this today while making a session prep Master Macro. (one session needed to prep percussion, another session had no percussion so could skip that step).

              I was able to convert the Master Macro to a script and get things cookin'...but just curious for future reference if doing if-then with the macro building blocks might be a possibility.

              Thanks,
              nick

              PS - Shout out to you @Chris_Shaw ... it was a script that you posted on the forum that I was able to reverse engineer to get my session prep scrip running!

              1. Kitch Membery @Kitch2022-09-16 02:04:16.390Z

                Hi Nick,

                This can certainly be done.

                Implementing this kind of scenario really depends on what determines when Macro 2 is run or not. If you can determine that, then I'm sure I could muster up an example of how you'd do it.

                Also be sure to check out this video on how to write if/else statements (although this currently can't be done ion the Macro editor);

                1. Nnick krill @nick_krill
                    2022-09-16 12:52:29.926Z

                    Ah, thanks for that video link! (And for making all those tutorial videos!)

                    For the session prep example I mentioned above, Macro 2 would run is a track name has a certain prefix.

                    So, for example, if any track names are found with the prefix "P!" Macro 2 would run. If no tracks are found with that prefix the Master Macro would skip on to Macro 3.

                    -nick

                    1. Kitch Membery @Kitch2022-09-16 21:40:46.822Z

                      So I can make the variable names make sense... what does the prefix of "P" prefix stand for stand for?

                      1. In reply tonick_krill⬆:
                        Kitch Membery @Kitch2022-09-16 21:54:20.721Z

                        Hi @nick_krill,

                        You could do it something like this;

                        function getSessionFileName() {
                            //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];
                        
                            return sessionFileName;
                        }
                        
                        function macroOne() {
                            //Add Macro 1 converted to Javascript here
                        }
                        
                        function macroTwo() {
                            //Add Macro 2 converted to Javascript here
                        }
                        
                        function macroThree() {
                            //Add Macro 3 converted to Javascript here
                        }
                        
                        function main() {
                            //Get the Session File Name
                            const sessionFileName = getSessionFileName();
                        
                            //get boolean value from Session Prefix
                            const runMacroTwo = sessionFileName.endsWith("P");
                        
                            //Run Macro 1
                            macroOne();
                        
                            if (runMacroTwo === true) {
                                //Run Macro 2
                                macroTwo();
                            }
                        
                            //Run Macro 3
                            macroThree();
                        }
                        
                        main();
                        

                        Let me know if that makes sense. :-)

                        Rock on!

                        1. Nnick krill @nick_krill
                            2022-09-17 14:19:52.329Z

                            Hi Kitch,

                            Ah interesting, thanks! Yeah I think I'm following that. Just to double check, the script you posted has to do with a "P" in the session file name, right?

                            Maybe I didn't explain my example well, but I was referring to a track name beginning with "P" like "P Shaker," or "P claps" (I do a batch rename, add "P" to the front and then SoundFlow identifies tracks by track name Prefix and work some of its magic.)

                            In either case, would the general principles be the same?

                            1. Kitch Membery @Kitch2022-09-18 17:49:58.778Z

                              Hi Nick,

                              Yes it would :-)

                              Something like this should work for that;

                              function macroOne() {
                                  //Add Macro 1 converted to Javascript here
                              }
                              
                              function macroTwo() {
                                  //Add Macro 2 converted to Javascript here
                              }
                              
                              function macroThree() {
                                  //Add Macro 3 converted to Javascript here
                              }
                              
                              function main() {
                                  const selectedTrackName = sf.ui.proTools.selectedTrack.normalizedTrackName;
                                  const runMacroTwo = selectedTrackName.startsWith("P ");
                              
                                  //Run Macro 1
                                  macroOne();
                              
                                  if (runMacroTwo === true) {
                                      //Run Macro 2
                                      macroTwo();
                                  }
                              
                                  //Run Macro 3
                                  macroThree();
                              }
                              
                              main();