No internet connection
  1. Home
  2. How to

Is there a more robust method than DoForEachSelectedClip?

By Yujiro Yonetsu @Yujiro_Yonetsu
    2022-02-23 22:04:57.824Z

    Hello,

    I am working on a script that utilizes clipDoForEachSelectedClip.

    However, this has some strange properties that make it not very useful.
    (Like the fact that the time counter is forced to be a sample......)

    Is there any other way to do the same thing?

    For example, here's a script that I'm having trouble making right now

    
    function safePrepost() {
    
        sf.ui.proTools.menuClick({
            menuPath: ["View", "Main Counter", "Timecode"],
        });
    
        sf.wait({ intervalMs: 50, });
    
        sf.keyboard.press({
            keys: "tab",
        });
    
        sf.wait({ intervalMs: 50, });
    
        sf.keyboard.press({
            keys: "shift+tab",
        });
    
        sf.wait({ intervalMs: 90, });
    
        var space2 = sf.ui.proTools.selectionGet().selectionLength.split(":").join("");
    
        var space2num = Number(space2);
    
        if (space2num >= 1) {
            sf.keyboard.press({
                keys: "option+control+tab",
            });
    
            sf.ui.proTools.nudgeSet({
                value: "00:00:07:00.00",
            });
    
            sf.keyboard.press({
                keys: "command+numpad plus",
            });
        } else {
            sf.keyboard.press({
                keys: "option+control+tab",
            });
            sf.ui.proTools.menuClick({
                menuPath: ["Edit", "Trim Clip", "To File End"],
            });
        }
    
        sf.wait({ intervalMs: 90, });
    
        //sf.keyboard.press({
        //    keys: "control+tab",
        //});
    
        sf.ui.proTools.nudgeSet({
            value: "00:00:02:00.00",
        });
    
        sf.wait({ intervalMs: 90, });
    
        sf.keyboard.press({
            keys: "option+numpad minus",
        });
    
        sf.wait({ intervalMs: 90, });
    
        sf.ui.proTools.nudgeSet({
            value: "00:00:07:00.00",
        });
    
        sf.wait({ intervalMs: 90, });
    
        //sf.keyboard.press({
        //    keys: "tab",
        //});
    
        sf.wait({ intervalMs: 90, });
    }
    
    
    sf.ui.proTools.clipDoForEachSelectedClip({
        action: safePrepost,
        onError: 'Continue',
    });
    

    I want to extend the beginning and end of all selected clips.

    I'd like to get some suggestions.
    Please help me!

    Best

    • 3 replies
    1. Yujiro Yonetsu @Yujiro_Yonetsu
        2022-02-28 00:56:59.219Z

        Hello.
        I've been thinking about it.

        Is it possible to do something like what is in this thread for clips?

        Or am I taking a futile detour?

        Please advise.

        1. Yujiro Yonetsu @Yujiro_Yonetsu
            2022-03-24 14:44:22.694Z

            hmmmmmm :(
            I have been thinking about it a lot but can't come up with a method.
            I would appreciate any help anyone can give me.
            Best!

          • In reply toYujiro_Yonetsu:

            Hi Yujiro,

            It's pretty difficult to write a stable implementation of this with all the corner cases (ie. fades, crossfades, etc., overlapping clips), which is why SoundFlow needs to be in Samples mode to keep track of the current selection while doing its work.

            If the only thing you don't like about the current implementation is the fact it switches to Samples, you could just switch to another time factor while doing your processing for each clip and switch back to Samples. That would be a stable approach.

            If you want to come up with an entirely new implementation, it's likely to be a lot of work to get it working for all corner cases. The clipDoForEachSelectedClip is hugely complex internally.