No internet connection
  1. Home
  2. How to

Moving Clips to "Dump" Tracks while Tracking

By Nathan Salefski @nathansalefski
    2023-07-17 19:58:10.057Z2023-07-17 20:33:52.182Z

    I saw this post (What would be the best way to move a section up/down across tracks in PT?) about moving clips to tracks above or below and wanted to repurpose it to speed up my current tracking process. When tracking, I have a record track and two "Dump" tracks below to quickly trim and comp a vocal. It all happens incredibly quickly -- to the point I wonder if this would be slower -- but I wanted to see if automating mouse drags would be quicker. Is there a way to speed up the mouse drag speed? Here's where I am currently. It's almost by accident sort of multifunctional. If I select a region of a clip and hover over it it will take that selection and drag it down to the next track. If I click at any point in a clip it will select from that point to the end of the clip and drag it down. Any suggestions on mouse drag speed?

    //Activate Pro Tools
    sf.ui.proTools.appActivate();
    sf.ui.proTools.mainWindow.invalidate();
    
    //Get Current Tracks Height
    const tHeight = sf.ui.proTools.selectedTrack.frame.h;
    
    //Separate Clip at Selection
    sf.ui.proTools.menuClick({
        menuPath: ["Edit", "Separate Clip","At Selection"],
    });
    
    //Define Tool Cluster
    const toolClus = sf.ui.proTools.mainWindow.cursorToolCluster;
    
    //Activate Grabber
    toolClus.buttons.allItems[4].elementClick();
    
    //Get Mouse Position
    const originalMousePosition = sf.mouse.getPosition().position;
    
    //Define Drag
    const startPosition = originalMousePosition
    const endPosition = {"x": originalMousePosition.x, "y": originalMousePosition.y + tHeight}
    
    //Drag Down
    sf.mouse.simulateDrag({
        startPosition,
        endPosition,
    });
    
    //Return Mouse to Original Position
    sf.mouse.setPosition({ position: originalMousePosition,});
    
    //Activate Selector Tool
    toolClus.buttons.allItems[3].elementClick();
    
    Solved in post #3, click to view
    • 7 replies
    1. Nathan Salefski @nathansalefski
        2023-07-17 20:38:40.680Z2023-07-18 00:31:11.773Z

        I also saw this post (Simulate mouse drag from relative UI position #post-10) about making the steps into a function for faster dragging but can't seems to get the format correct. It's not grabbing the clip:

        //Activate Pro Tools
        sf.ui.proTools.appActivate();
        sf.ui.proTools.mainWindow.invalidate();
        
        //Fast Drag Funtion
        function fastDrag(startPos, endPos)
          {
            const timeToWaitBeforeDropping = 100;
        
            sf.mouse.down({ position: startPos,});
        
            sf.mouse.drag({ position: endPos });
        
            sf.wait({ intervalMs: timeToWaitBeforeDropping });
            
            sf.mouse.up({ position: endPos });
          };
        
        //Get Mouse Position
        const mousePos = sf.mouse.getPosition().position;
        
        //Get Current Tracks Height
        const tHeight = sf.ui.proTools.selectedTrack.frame.h;
        
        //Define End Drag
        const endDrag = {x: mousePos.x, y: mousePos.y + tHeight}
        
        //Define Tool Cluster
        const toolClus = sf.ui.proTools.mainWindow.cursorToolCluster;
        
        //Separate Clip at Selection
        sf.ui.proTools.menuClick({
          menuPath: ["Edit", "Separate Clip","At Selection"],
        });
        
        //Activate Grabber
        toolClus.buttons.allItems[4].elementClick();
        
        //Fast Drag Clip
        fastDrag(mousePos,endDrag);
        
        //Return Mouse to Original Position
        sf.mouse.setPosition({ position: mousePos,});
        
        //Activate Selector Tool
        toolClus.buttons.allItems[3].elementClick();
        

        @Kitch?

        1. Mitch Willard @Mitch_Willard
            2023-07-18 05:05:54.021Z2023-07-18 05:17:17.134Z

            hey @nathansalefski

            This would probably be more stable and probably quicker that a mouse drag.

            
            function moveClipsToTrack(track) {
                function selectTrackDelta(delta) {
                    const firstSelectedTrackName = sf.ui.proTools.selectedTrackNames[0];
                    const visibleTrackNames = sf.ui.proTools.visibleTrackNames;
                    const visibleTrackIndex = visibleTrackNames.findIndex(n => n === firstSelectedTrackName);
                    if (visibleTrackIndex < 0) return;
            
                    let newTrackIndex = visibleTrackIndex + delta;
                    if (newTrackIndex < 0) return;
                    if (newTrackIndex >= visibleTrackNames.length) return;
            
                    sf.ui.proTools.trackSelectByName({
                        names: [visibleTrackNames[newTrackIndex]]
                    });
                };
            
                sf.ui.proTools.appActivate();
                sf.ui.proTools.appActivateMainWindow();
            
                let originalTrack = sf.ui.proTools.selectedTrackNames[0]
            
                sf.ui.proTools.getMenuItem('Edit', 'Cut').elementClick();
            
                selectTrackDelta(track);   
            
                sf.ui.proTools.getMenuItem('Edit', 'Paste').elementClick();
            
                sf.ui.proTools.trackGetByName({ name: originalTrack, makeVisible: true }).track.trackSelect();
            };
            
            moveClipsToTrack(1) // for next track
            // moveClipsToTrack(-1) //  for previous track
            
            

            just add 1 for the next track below, or -1 for the previous track above to moveClipsToTrack(numberGoesHere)

            Mitch

            Reply4 LikesSolution
            1. Nathan Salefski @nathansalefski
                2023-07-18 22:26:12.511Z

                It works very well thank you! I'm going to leave this open just so I can be informed of how to do mouse drags quickly in the future

                1. Kitch Membery @Kitch2023-07-19 22:20:58.783Z

                  Hi @nathansalefski,

                  It looks like @Mitch_Willard beat me to it. And his approach is the best approach.

                  Mouse and Keyboard simulation is the least robust way of using SoundFlow to control things. If there is something specific you feel requires fast dragging it would be better to open a new thread for that.

                  Thanks in advance :-)

                  1. Nathan Salefski @nathansalefski
                      2023-07-19 22:23:08.011Z

                      Understood thank you both @Mitch_Willard!

                      1. Kitch Membery @Kitch2023-07-19 22:24:31.775Z

                        Rock on!

                        Hopefully, anything that you find requiring fast dragging can be done in a better way by using UI automation.

                  2. In reply toMitch_Willard:
                    Ddanielkassulke @danielkassulke
                      2023-07-26 06:39:18.927Z

                      This is spectacular!