No internet connection
  1. Home
  2. Macro and Script Help

Consolidate tracks in sequence

By Joao p Mendonca @Joao_p_Mendonca
    2024-09-04 16:44:34.064Z

    Title

    Consolidate tracks in sequence

    What do you expect to happen when you run the script/macro?

    I want to consolidate all tracks in sequence, i need SF learn that the track was consolidated and go to the next track until there are no more track, it is only doing on a single track

    Are you seeing an error?

    What happens when you run this script?

    it consolidates one track and stops

    How were you running this script?

    I clicked the "Run Script" or "Run Macro" button in SoundFlow

    How important is this issue to you?

    5

    Details

    {
        "inputExpected": "I want to consolidate all tracks in sequence, i need SF learn that the track was consolidated and go to the next track until there are no more track, it is only doing on a single track",
        "inputIsError": false,
        "inputWhatHappens": "it consolidates one track and stops",
        "inputHowRun": {
            "key": "-MpfwYA4I6GGlXgvp5j1",
            "title": "I clicked the \"Run Script\" or \"Run Macro\" button in SoundFlow"
        },
        "inputImportance": 5,
        "inputTitle": " Consolidate tracks in sequence"
    }

    Source

    //Macro converted to script
    
    
    sf.keyboard.press({
        keys: "cmd+j",
    });
    
    (throw 'context missing').elementWaitFor({
        waitType: "Disappear",
    });
    
    sf.wait({
        intervalMs: 5000,
    });
    
    sf.keyboard.press({
        keys: "down",
    });
    
    //Calling command "Repeat - Multiple…" from package "Logic Pro" (installed from user/pkg/version "uOwKfD26NbWKAWotin3dmnSne7B3/cli50xtc200015210vyksy31z/clv5sg8o2000dos10k47oltn0")
    sf.soundflow.runCommand({
        commandId: 'user:cli50xtc200015210vyksy31z:clijh236g00002a10lu6m2wya#clijp7yb400069010a1am9nfv',
        props: {}
    });
    
    
    

    Links

    User UID: sEMv0yHxd3bYIfRjlnYDeF7AZPi2

    Feedback Key: sffeedback:sEMv0yHxd3bYIfRjlnYDeF7AZPi2:-O5xv5oy3OwXgybQUoYO

    Feedback ZIP: XfsN2W1Md6/J3uMxILXEbsl105juHzACTknoKr9aS9jh3gKMVZzTIP5BHEs3mGuJ9EKJQPtytqx7qHOvYZ2hGMzR7mVIeOEmnRa29rgbGFcJaymPqmNlOmgYwuuGfvZkqqiZPxzVowuMno7IlkXR3Yc25dbgh+bww0PNqLwT+fZoavExfttc+IMgY6trZsUSU3wbHOB8JhOLf59yPGGbNKC42QfybdH4UPbzj2199jkqYDu1KAA7BO5VnR/3FR8JtnzF+7/1wI6hT2MwM3GXx23i0NnEH3JZcA4BRq0unwRHwxtJb6mUXWsI/pMEr9btH52iV8G4poBnpP9TTH8lqw==

    • 2 replies
    1. Kitch Membery @Kitch2024-09-05 23:47:37.252Z

      Hi @Joao_p_Mendonca,

      You could use a script like this.

      const logic = sf.ui.logic
      logic.appActivate();
      logic.invalidate();
      
      const mainWindow = logic.mainWindow;
      const tracksGroup = mainWindow.groups.whoseDescription.is("Tracks").first;
      const tracksArea = tracksGroup.groups.whoseDescription.is("Tracks").allItems[1];
      const trackHeadersGroup = tracksArea
          .splitGroups.first
          .splitGroups.allItems[1]
          .scrollAreas.first
          .groups.whoseDescription.is('Tracks header').first;
      
      const totalTrackCount = trackHeadersGroup.children.length;
      
      // Function to get the selected track's description
      function getFirstSelectedTrackDescription() {
          const firstSelectedTrackHeader = trackHeadersGroup.getElements('AXSelectedChildren').first;
          return firstSelectedTrackHeader.invalidate().getString("AXDescription");
      }
      
      // Function to get the number of track regions
      function getTrackRegionCount() {
          const tracksContent = tracksArea.splitGroups.first
              .splitGroups.allItems[1]
              .scrollAreas.allItems[1]
              .groups.whoseDescription.is("Tracks contents").first;
      
          const trackContent = tracksContent.children
              .whoseRole.is("AXLayoutArea")
              .whoseDescription.is(getFirstSelectedTrackDescription())
              .first;
      
          return trackContent.children.whoseRole.is("AXLayoutItem").length;
      };
      
      function moveToNextTrack() {
          sf.keyboard.press({ keys: "down" });
      }
      
      function consolidateRegions() {
          // Refresh Edit menu and Join
          logic.getMenuItem("Edit",).elementClick();
          logic.getMenuItem("Edit", "Bounce and Join",).elementClick();
      
          if (logic.getMenuItem("Edit", "Bounce and Join", "Join").isEnabled) {
              logic.getMenuItem("Edit", "Bounce and Join", "Join").elementClick();
              sf.wait({ intervalMs: 200 });
      
              // Get the region count
              const oldRegionCount = getTrackRegionCount();
      
              // It the region count is greater than 1
              if (oldRegionCount > 1) {
                  // While region count does not equal 1 wait for 100ms
                  while (getTrackRegionCount() !== 1) {
                      sf.wait({ intervalMs: 100 });
                  }
              }
      
              // Pause for 1 second before moving on.
              sf.wait({ intervalMs: 1000 });
          } else {
              sf.ui.logic.childrenByRole("AXMenuBar").first.elementClick({ actionName: "AXCancel" })
              sf.wait({ intervalMs: 200 });
          }
      }
      
      function main() {
          const repetitions = totalTrackCount;
      
          /* const repetitions = Number(sf.interaction.displayDialog({
              buttons: ["Cancel", "Continue"],
              defaultButton: "Continue",
              cancelButton: "Cancel",
              prompt: "How many consecutive tracks would you like to consolidate?",
              title: "Join Regions",
              defaultAnswer: "",
          }).text); */
          
          for (let i = 0; i < repetitions; i++) {
      
              consolidateRegions();
      
              if (i !== (repetitions - 1)) moveToNextTrack();
          }
      
          log("Consolidation complete");
      }
      
      main();
      

      Select the first track, and only the first track, in the Tracks Area of Logic Pro's main window. Then run the script.

      The script will go through and Consolidate/Join all the regions on each track in the Tracks Area.

      I hope that helps.

      1. JJoao p Mendonca @Joao_p_Mendonca
          2024-11-08 17:55:22.288Z

          Thank you so much I solved it already