Is there a way to repeat a macro x times or loop it?
- Christian Scheuer @chrscheuer2020-10-02 14:31:10.498Z
Hi Tilman,
Currently, we don't have control flow actions for the Macro Editor.
But you can convert your macro into a script and in your script, you can do repetition via a for loop or while loop, etc.Do you need your repetition to always be the same number, or based on a number the user presses, or using some even different logic? That's what scripts are great for.
You can see an example here, where we're repeating an action until the end of the original selection is reached.
There are many options, so the best way to achieve the desired logic, is to try to list up the step-by-step actions you wish your macro to take, and then we'll take it from there.
Christian Scheuer @chrscheuer2020-10-02 14:32:26.877Z
The simplest loop form in a script would be the for loop.
Usually, for loops count from 0 and then iterate as long as the iteration variable is less than the desired number of iterations.
So, if we usei
for the iteration variable and we start a0
and we want5
total iterations, we'd put it like this://Loop 5 times for(let i=0; i<5; i++) { //Here you put the stuff you want repeated 5 times }
- TTilman Hahn @Tilman_Hahn
Hi Christian,
thanks that worked really well!
I'm now trying to let the loop recognize that there are no more clips left on the timeline and that he should jump back to the start of the session, to perform the same loop on the track below. The main problem for me is to tell the loop to stop when there are no more clips or tracks left.Christian Scheuer @chrscheuer2020-10-07 11:16:50.583Z
Hi Tilman,
We have built-in functions in SoundFlow for iterating through all clips in the timeline, and also for each selected track. But it's much easier to help you if we know what you'd like to do for each clip / the overall workflow. Can you explain a bit more what exactly you'd like to happen?
- In reply tochrscheuer⬆:
Andrew Piland @Andrew_Piland
This script has done wonders for me. Is there any way to have a window pop up beforehand asking how many times you want the script looped instead of going into the code and manually adjusting it?
Christian Scheuer @chrscheuer2024-06-21 14:25:10.027Z
Yes :)
var numberOfTimes = Number(prompt(`How many times would you like to repeat this action?`)); if (isNaN(numberOfTimes)) throw `Please specify a number`; //Loop `numberOfTimes` times for(let i=0; i<numberOfTimes; i++) { //Here you put the stuff you want repeated `numberOfTimes` times }
Andrew Piland @Andrew_Piland
That works perfectly, thanks!