No internet connection
  1. Home
  2. How to

Creating a new track with any plugin

By Mike Avenaim @Mike_Avenaim
    2020-12-03 21:08:36.835Z

    I wanting to create a new "Stereo / Instrument / Sample Based" track that I can insert any plugin I want on in the first slot. This will trigger from a StreamDeck.

    I have this code so far and it wont do anything except open the "New track" UI:

    sf.ui.proTools.menuClick({
        menuPath: ["Track","New..."],
        looseMatch: false,
        targetValue: "Toggle",
        forceClick: false,
        executionMode: "Foreground",
        onError: "ThrowError",
    });
    
    sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.elementWaitFor();
    
    // Selectring Stereo Track
    sf.keyboard.press({
        keys: "cmd+right",
    });
    
    // Selecting Instrument Track
    sf.keyboard.press({
        keys: "cmd+down",
        repetitions: 5,
        fast: false,
    });
    

    Any suggestions would be fantastic. Thank you!

    Solved in post #2, click to view
    • 19 replies
    1. Hey Mike,

      To answer your initial question. Here is how you can create that Instrument Track:

      const newTracksWin = sf.ui.proTools.windows.whoseTitle.is('New Tracks').first;
      
      sf.ui.proTools.appActivateMainWindow();
      
      sf.ui.proTools.menuClick({ menuPath: ["Track", "New..."], })
      
      newTracksWin.elementWaitFor();
      
      newTracksWin.popupButtons.first.popupMenuSelect({ menuPath: ["Stereo"] });
      
      newTracksWin.popupButtons.allItems[1].popupMenuSelect({
          menuPath: ["Instrument Track"],
      });
      
      newTracksWin.popupButtons.allItems[2].popupMenuSelect({
          menuPath: ["Samples"],
      });
      
      newTracksWin.buttons.whoseTitle.is('Create').first.elementClick();
      
      newTracksWin.elementWaitFor({ waitType: "Disappear" });
      

      But my suggestion for what you want to ultimately do would be to use Track Presets. Make a Track Preset for that Instrument track with the plugin you want on the first insert slot and then use SoundFlow to create it.
      Here's an example of how I create a Kontakt instrument track. You'll have to change the menu paths to the location of your track preset.

      const newTracksWin = sf.ui.proTools.windows.whoseTitle.is('New Tracks').first;
      
      sf.ui.proTools.appActivateMainWindow();
      
      sf.ui.proTools.menuClick({ menuPath: ["Track", "New..."] });
      
      newTracksWin.elementWaitFor();
      
      // Change path here
      newTracksWin.popupButtons.allItems[1].popupMenuSelect({
          menuPath: ["Track Presets", "Raph", "Production", "Kontakt"],
      });
      // And here
      newTracksWin.popupButtons.first.popupMenuSelect({
          menuPath: ["Kontakt.VI"],
      });
      
      newTracksWin.buttons.whoseTitle.is('Create').first.elementClick();
      
      newTracksWin.elementWaitFor({ waitType: "Disappear" });
      

      Let me know if that makes sense!

      Reply2 LikesSolution
      1. MMike Avenaim @Mike_Avenaim
          2020-12-03 23:26:04.981Z

          Ok great. Good idea with the track presets. Ill try that. What is the "KONTAKT.VI" pointing to?

          1. DDamon Castillo @Damon_Castillo
              2021-05-17 21:42:26.895Z

              I'm also wondering what "Kontakt.VI" is pointing to... Haven't gotten this to work just yet.

              1. Check my reply below!

            • MMike Avenaim @Mike_Avenaim
                2020-12-03 23:41:14.964Z

                im getting hung up here:

                Could not click popup menu item (Create Kontakt 5: Line 10)
                Could not find menu item with name: Track Presets -> Avenaim -> Stream Deck -> Kontakt 5

                Its just stopping at the New Track UI element

                1. MMike Avenaim @Mike_Avenaim
                    2020-12-03 23:42:54.233Z

                    I fixed it... I had one wrong thing in the chain!

                    1. Perfect! Glad that worked out!

                  • Kitch Membery @Kitch2020-12-04 00:33:17.214Z

                    Hi @Mike_Avenaim ya champion!,

                    Just to add onto Raphael's excellent suggestions here. When working with popup menus its best not to use keyboard simulation... instead use the "Open & Select Item in Popup Menu" Macro Action.

                    So where you had this;

                    //Select "Stereo Track"
                    sf.keyboard.press({
                        keys: "cmd+right",
                    });
                    

                    Will becomes this;

                    //Select "Stereo Track"
                    sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.popupButtons.first.popupMenuSelect({
                        menuPath: ["Stereo"],
                    });
                    

                    Rock on!

                    1. MMike Avenaim @Mike_Avenaim
                        2020-12-04 00:50:43.086Z

                        Killer... ill replace that now

                        Thank you

                        1. Kitch Membery @Kitch2020-12-04 00:53:27.886Z

                          @raphaelsepulveda's scripts already use the "Open & Select Item in Popup Menu" code so no need to change his scripts :-)

                          Just thought I'd give you the heads up. :-)

                          1. MMike Avenaim @Mike_Avenaim
                              2020-12-04 00:55:57.428Z

                              Yes, i caught that! Thanks man

                        2. DDamon Castillo @Damon_Castillo
                            2021-05-17 21:39:15.746Z

                            Total newbie here, but I would like to do the same as Mike. I'm getting ...
                            New Kontakt Track failed, could not click popup menu item (New Kontakt Track: Line 10).
                            Any ideas on what I'm doing wrong? Thanks!

                            1. Hey Damon!

                              I have a command for creating new tracks with track presets in my utilities package that can do this for you!

                              I'd suggest you try that first since all the bugs have been worked out. If you're still having issues let me know and I'll take a look!

                              1. DDamon Castillo @Damon_Castillo
                                  2021-05-18 21:06:58.314Z

                                  Raphael!
                                  It works brilliantly! Thanks!
                                  Damon

                            2. I
                              In reply toMike_Avenaim:
                              Iuri Cunha @Iuri_Cunha
                                2023-12-08 21:28:37.383Z

                                Hi guys, every time I try to run this script or Raphael's macro I get an error saying it could not click the menu item with my track preset's name even though I put the preset menu with the correct path. Any idea of what I might be the issue?

                                1. Could you give us more information? What is your preset's path and how are you putting it in the script or the macro? A video of it failing always helps a ton.

                                  1. IIuri Cunha @Iuri_Cunha
                                      2023-12-11 23:29:01.648Z

                                      Hi, This is an example of the script was running to make a new track from a preset I called "Piano". I had it working for a couple of days but for some reason it just stopped, and all other scripts that I used to make other tracks from presets aren't working. I always get an error on line 10. It's like it's unable to find the "Track Preset" and "User" buttons in the menu. Whenever I try to run your version of it from the utilities package I also get an error on line 31 and get stuck with the new track window. Any Ideas why this might be happening?

                                      const newTracksWin = sf.ui.proTools.windows.whoseTitle.is('New Tracks').first;
                                      
                                      sf.ui.proTools.appActivateMainWindow();
                                      
                                      sf.ui.proTools.menuClick({ menuPath: ["Track", "New..."] });
                                      
                                      newTracksWin.elementWaitFor();
                                      
                                      // Change path here
                                      newTracksWin.popupButtons.allItems[1].popupMenuSelect({
                                          menuPath: ["Track Presets","User"]
                                      });
                                      // And here
                                      newTracksWin.popupButtons.first.popupMenuSelect({
                                          menuPath: ["Piano"],
                                      });
                                      
                                      newTracksWin.buttons.whoseTitle.is('Create').first.elementClick();
                                      
                                      newTracksWin.elementWaitFor({ waitType: "Disappear" });
                                      
                                      1. Mmm, I've recreated your track preset structure to try and repro the error but no dice.

                                        I'm thinking maybe this could be that old Melodyne folder bug from a while back. Check out this thread so you know what I'm talking about. Basically, in rare circumstances, there's a chance that Pro Tools creates a Melodyne folder inside one of the track preset folders which breaks the ability to select a menu item in the same popup menu you're having trouble with. Could you go to your Track Presets folder in Finder and see if there is a Melodyne folder somewhere in there? If so, delete it and try again.

                                        1. IIuri Cunha @Iuri_Cunha
                                            2023-12-12 01:43:45.165Z

                                            That was it!! Thank you!! It works now!