repeat macro using n times variable w/ user prompt
Hi,
I'm looking to create a macro which:
- prompts for a number variable
- then repeats a macro by that number
In this case, I am looking to run the iZotope Loudness Control plugin on a given region, clicking the "analyze" then "render" buttons, then selecting the next clip in the timeline.
I think I understand the scripts for the each element but I don't know how to tie them together. The macro to be repeated is:
sf.ui.proTools.audioSuiteOpenPlugin({
category: "Sound Field",
name: "iZotope RX Loudness Control",
});
sf.ui.proTools.firstAudioSuiteWindow.audioSuiteSelectPreset({
presetMenuPath: ["Calm_2"],
});
sf.ui.proTools.firstAudioSuiteWindow.buttons.whoseTitle.is('Analyze').first.elementClick();
sf.wait({
intervalMs: 3500,
});
sf.ui.proTools.firstAudioSuiteWindow.audioSuiteRender();
sf.wait({
intervalMs: 3000,
});
/* sf.ui.proTools.clipSelectNextFullClip(); */
sf.keyboard.press({
keys: "up, tab, shift+tab",
});
I know this script is the "repeat n times"
/**@type {{
repetitions,
action?: () => void,
}} */
const { repetitions, action } = event.props;
for (var i = 0; i < repetitions; i++) {
action();
}
And the user prompt is something like:
var repeat = prompt("How many?");
I just don't know how to tie all these things together.
Thanks!
- Christian Scheuer @chrscheuer2023-03-22 14:33:17.302Z
Hi Brian,
You should be able to do something like this:
var repetitions = Number(prompt("How many?")); if (isNaN(repetitions)) throw 0; //Cancel if they didn't enter a number //repeat n times for(var i=0; i<repetitions; i++) { //insert here what should be repeated log(`This is iteration ${i+1}`); }
Christian Scheuer @chrscheuer2023-03-22 14:35:04.770Z
then selecting the next clip in the timeline
SoundFlow has built-in functions to help doing something for each selected clip.
Here's an example:- In reply tochrscheuer⬆:B@briannaas
This is perfect, thanks Christian! As a different variation, is there a way that a number prompt can trigger different macros? Eg, if I enter "1" it will run macro A, "2" it will run macro B, etc.
Christian Scheuer @chrscheuer2023-05-08 17:56:59.187Z
Yes, you could set that up, but it'd be better to start as a new thread :)