No internet connection
  1. Home
  2. How to

Copy a Selection to Track Below

By Mike De Lay @Mike_De_Lay
    2023-03-29 20:46:05.048Z

    I would love to be able to make a selection, then by pushing a stream deck button - copy the selection (cmd +c), move the selection down to the next track (;), and then paste the selection on that new track (cmd +v)

    Seems pretty straight forward. Is there a way to set that up?

    • 10 replies
    1. O

      Check out my package AAF ORGANIZER - COPY/CUT to Target Track inside you'll find a template called Vertical Clip Move TEMPLATE create your own preset with your desired settings and enjoy!

      1. In reply toMike_De_Lay:
        Chris Shaw @Chris_Shaw2023-03-29 21:28:00.859Z2023-03-30 01:02:35.695Z

        This should do it:
        (Be sure to read the comments to modify which destination track is selected)

        //To change which track below the selected track to paste to, change the value of trackIndexOffset
        // ex to paste to third track below the selected track, use  trackIndexOffset = 3
        // You can use a negative number to paste to tracks above selected track
        
        // This script assumes that link track and edit selection is turned on (SF requires it for scripts to work)
        // and that the track width is the same on source and destination tracks
        
        const trackIndexOffset = 1
        
        //Function to check if PT is recording
        function isRecording() {
            const transportViewCluster = sf.ui.proTools.mainWindow.transportViewCluster;
            let recordButton = transportViewCluster.transportButtons.buttons.whoseTitle.is("Record Enable").first;
            return recordButton.value.invalidate().value.endsWith("Is Recording");
        }
        
        sf.ui.proTools.appActivateMainWindow();
        sf.ui.proTools.mainWindow.invalidate();
        
        //Get visible track names
        const visibleTrackNames = sf.ui.proTools.visibleTrackNames
        
        //Get selected track name
        const selectedTrackName = sf.ui.proTools.selectedTrackNames[0]
        
        //Get the index of the selected track
        const selectedTrackIndex = visibleTrackNames.indexOf(selectedTrackName)
        
        // Get the paste destination track name by increasing the selected track's index by the value of trackIndexOffset
        const destinationTrackName = visibleTrackNames[selectedTrackIndex + trackIndexOffset]
        
        //copy selection
        sf.ui.proTools.menuClick({
            menuPath: ["Edit", "Copy"],
        });
        
        //Paste routine if PT is recording
        if (isRecording()) {
            //Use keyboard to navigate to destination track
            sf.keyboard.press({
                keys: trackIndexOffset > 0 ? "semicolon" : "p",
                repetitions: Math.abs(trackIndexOffset)
            });
        
            //Paste on destination track
            sf.ui.proTools.menuClick({
                menuPath: ["Edit", "Paste"],
            });
        
            //Use keyboard to navigate to original selected track
            sf.keyboard.press({
                keys: trackIndexOffset < 0 ? "semicolon" : "p",
                repetitions: Math.abs(trackIndexOffset)
            });
        
        } else {
        
            //If PT is not recording use this:
        
            //Select destination track
            sf.ui.proTools.trackSelectByName({
                names: [destinationTrackName],
                deselectOthers: true
            })
        
            //Paste on destination track
            sf.ui.proTools.menuClick({
                menuPath: ["Edit", "Paste"],
            });
            //Reselect original track
            sf.ui.proTools.trackSelectByName({
                names: [selectedTrackName]
            })
        }
        
        1. MMike De Lay @Mike_De_Lay
            2023-03-29 23:02:23.170Z2023-03-29 23:22:57.047Z

            CHRIS!!! This is KILLER! Is there a way that this can work while you're recording? For instance, we record a lot of video games. We record 3 takes, director calls out the select, and we move on, Typically I'll stop the recording and start it up again then pull the select to the track below. This script works PERFECTLY as long as you're not recording.

            1. I don't think it's possible to copy audio that is currently being recorded - with or without a macro.
              The next best thing would be to drop in and out markers as the director calls things out and edit afterwards.

              1. MMike De Lay @Mike_De_Lay
                  2023-03-29 23:41:06.867Z

                  You are correct. You can't do that. What we're doing is recording. Stoping record. Then start recording again later in the timeline. Then we make a selection from the clips that are not actively recording. This script works in play, and if the transport isn't moving, but it doesn't work if it's actively recording. Any idea if there is a tweak for that?

                  This just all happens so quickly.

                  TRULY appreciate your help with this!!!

                  1. Chris Shaw @Chris_Shaw2023-03-30 00:47:52.248Z2023-03-30 15:58:32.032Z

                    ahh, got it.
                    I edited the script above to use keypresses to navigate the tracks if PT is recording (not the most robust way to do it but it seems to work). Otherwise it uses the original routine to navigate tracks.

                    1. MMike De Lay @Mike_De_Lay
                        2023-03-30 20:51:32.120Z

                        You're a WIZARD <:{>

                        THANK YOU SO MUCH! This is one of two reasons I wanted Sound Flow for our studio. BOOM! THANK YOU!

                        1. Glad I could help

                          1. MMike De Lay @Mike_De_Lay
                              2023-04-12 18:53:36.170Z

                              Question for you....Sorry, I'm so new to all of this....is there a reason this script would not work all of a sudden?

                              1. Still works for me here.
                                Is it working when PT isn't recording or stopped?
                                Make sure keyboard focus is turned on as well