No internet connection
  1. Home
  2. How to

JavaScript help, how to add value in next element to current element.

By Iain Anderson @Iain_Anderson
    2022-02-27 21:20:57.503Z

    Hi there,

    Got my next script brewing but stuck on the proper syntax in JavaScript for adding a value in the next element to the current element. Usage case is as follows.

    I have a number of clips over a number of tracks in ProTools, what I want to achieve is to start with the first clip and have SoundFlow extend all clips to end at the start of the next clip. If they were all all the same track this would be easy. But that’s not possible. I know I could do it with a mix/edit group enabled but that will mess up any unwanted overlaps.

    Here’s my thinking so far…

    1. I’m gonna get SoundFlow to create an array of objects. The objects being the clip info I can learn from the ProTools timeline, specifically clip start and ProTools track name.

    2. Sort the array in time order

    3. (Here’s the bit I’m stuck with), is add a clip end to each object. The clip end will be the clip start of the next object in the array.

    4. Get SoundFlow to move back through the tracks and clips and extend to match selection which will be clip start - clip end.

    I’m not in the studio at the moment, but got a tight turn around on this one, so any script help ahead of actually trying it would be greatly appreciated.
    Will post the finished script back below once it’s working!

    @Kitch @raphaelsepulveda @chrscheuer

    Many thanks,

    Iain

    • 2 replies
    1. Hey @Iain_Anderson, I'm not sure if I'm understanding correctly but from what I gathered you could use the Pro Tools function Edit > Trim Clip > To File End to extend the ending of any selected clips. The cool thing about that is that it will respect the next clip on the timeline so it should give you your desired result without having to script it like you were suggesting.

      All you'd have to do is write a script that goes through each track one by one, select the desired clips and menu click on the "To File End" menu item.

      If I have some time later I'll whip up a script but figured I'll let you know of that since it seems you're on a time constraint.

      1. IIain Anderson @Iain_Anderson
          2022-02-27 23:06:05.877Z

          Thanks for the quick reply.

          Would that work going across tracks, for example…

          If clip 1 was on track 2, clip 2 was on track 4, clip 3 was on track 6.

          What I need is a way for clip 1 to extend to end where clip 2 starts on track 4, but keeping clip 1 on track 2 and clip 2 extends on track 4 to where clip 3 starts on track 6.

          The clips will always be across 6 or more tracks, and it’s unlikey that consecutive clips will be on the same track.

          I’ll give it a go when I get in to the studio tomorrow.

          Cheers,

          Iain