No internet connection
  1. Home
  2. How to

Transporting Selected Clip

By joseph @njs24
    2023-03-12 22:15:14.815Z

    Hi everyone,

    I'm looking for a Soundflow script that can quickly move a selected clip in Pro Tools to a specific group of tracks by name, for example, Hook 1, Hook 2, and Hook 3. The script should automatically check if the selected region in Hook 1 is occupied and if it is, move the clip to Hook 2 or Hook 3, provided the regions on those tracks are free.

    Since I'm planning to use this script during vocal tracking, I'm hoping to achieve this with the least amount of steps possible.

    I've seen a few related questions on the forum, but none of the scripts there have worked for me. I also tried using the following script, but it wasn't working:

    function moveSelectedClipsToHookTracks() {
      var trackNames = ['Hook 1', 'Hook 2'];
      var originalSelection = sf.ui.proTools.selectionGetInSamples();
    
      for (var i = 0; i < trackNames.length; i++) {
        var trackName = trackNames[i];
        var track = sf.project.getActiveSequence().getTrackByName(trackName);
        var clips = track.clips.filter(function(clip) {
          return clip.time < originalSelection.selectionStart || clip.time > originalSelection.selectionEnd;
        });
        if (clips.length == 0) {
          // No clips on this track, so move the selection here
          sf.ui.proTools.trackSelectByName({names: [trackName], deselectOthers: true});
          var editPaste = sf.ui.proTools.getMenuItem('Edit', 'Paste');
          if (!editPaste.isEnabled) throw 'Cannot paste here';
          editPaste.elementClick({}, 'Could not paste clip');
          break;
        } else {
          // There are clips on this track, so find the first empty spot and move the selection there
          clips.sort(function(a, b) {
            return a.time - b.time;
          });
          var emptySpot = null;
          for (var j = 0; j < clips.length; j++) {
            var nextClip = clips[j + 1];
            if (!nextClip) {
              emptySpot = {time: clips[j].endTime};
              break;
            } else if (nextClip.time - clips[j].endTime >= originalSelection.selectionDuration) {
              emptySpot = {time: clips[j].endTime};
              break;
            }
          }
          if (emptySpot) {
            sf.ui.proTools.selectionSetInSamples({
              selectionStart: emptySpot.time,
              selectionEnd: emptySpot.time + originalSelection.selectionDuration
            });
            sf.ui.proTools.trackSelectByName({names: [trackName], deselectOthers: true});
            var editPaste = sf.ui.proTools.getMenuItem('Edit', 'Paste');
            if (!editPaste.isEnabled) throw 'Cannot paste here';
            editPaste.elementClick({}, 'Could not paste clip');
            break;
          }
        }
      }
    }
    
    

    Any help would be greatly appreciated! Thanks in advance."

    • 1 replies
    1. N
      joseph @njs24
        2023-03-18 22:33:28.669Z

        Hi guys, any updates on this??