Enhancement for Macros

Questions, discussion and recipes for scripting and batch processing in Audacity.
See also the "Scripting" section of the Audacity manual.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
mafg1953
Posts: 199
Joined: Tue Nov 05, 2019 3:49 pm
Operating System: Windows 10

Enhancement for Macros

Post by mafg1953 » Sat Nov 07, 2020 12:38 am

Hi,

Not sure if this has been brought up before (or if there is a way to do it that I haven't found), but it would be nice if we could step through a macro one command at a time or execute a certain number of steps and then stop. It would help in design of longer Macros.

Thanks,

Mike

steve
Site Admin
Posts: 81229
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Enhancement for Macros

Post by steve » Sat Nov 07, 2020 10:46 am

mafg1953 wrote:
Sat Nov 07, 2020 12:38 am
it would be nice if we could step through a macro one command at a time or execute a certain number of steps and then stop. It would help in design of longer Macros.
That is exactly how I create Macros.

First I work out the steps by manually applying each step in turn. If it's a lot of steps, I write the steps down on paper.
I then add the first step to the macro, test, then undo, then add the next step, test, undo, add the next step...

Personally I find this approach much easier than trying to debug a long complex macro that doesn't work as expected.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

babag
Posts: 33
Joined: Fri Sep 18, 2020 10:09 pm
Operating System: Linux *buntu

Re: Enhancement for Macros

Post by babag » Sat Nov 07, 2020 5:49 pm

i do something similar too but i also can see a lot of value in this suggestion.

sometimes you can have something complex that seems like it's working and it's not until later that you run into an unanticipated scenario in which it does not behave as expected. in that kind of case this could be very handy.

babag

steve
Site Admin
Posts: 81229
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Enhancement for Macros

Post by steve » Sat Nov 07, 2020 6:53 pm

I expect that the GUI for macros will improve over time (it's rather basic at the moment, but at least it is usable).
For now, it would probably be possible to create a plug-in that takes the name of an existing Macro as its input, and allows you to step through the commands in that Macro one at a time.

I've not yet tested this, but I'm considering what is currently possible, and I think something like this could work:
1. Launch a "Step through Macro" effect.
2. Enter the name of an existing Macro in the "Step through Macro" effect GUI and click the "OK" or "Debug" button.
3. The effect reads the first command from the Macro file and runs it.
4. Press "Ctrl + R" to run the "Step through Macro" effect again. This time it reads the second line from the Macro file and runs that.
5. Repeat step 4 until the end of the Macro file is reached. The plug-in then resets.

There would also need to be some way to reset the plug-in.

Does that idea sound like it has legs?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

babag
Posts: 33
Joined: Fri Sep 18, 2020 10:09 pm
Operating System: Linux *buntu

Re: Enhancement for Macros

Post by babag » Sat Nov 07, 2020 8:07 pm

while i do think this sounds like a good idea, i haven't been around audacity closely enough to have a good sense of how it develops. i'd hate to see you go and do a bunch of work only to have it superceded by the next release. if macros are getting attention, it might not be the time to be putting as bunch of work into community enhancements. it does seem like there's a lot that has been and could be done from the developer end of things.

thanks,
babag

steve
Site Admin
Posts: 81229
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Enhancement for Macros

Post by steve » Sat Nov 07, 2020 8:42 pm

Audacity tends to develop quite slowly. It's a very small team of volunteers. There are no major changes to macros in the next version, so I think this could be worth the time investment. I'll see if I can create a "proof of concept" and then we can take it from there.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

mafg1953
Posts: 199
Joined: Tue Nov 05, 2019 3:49 pm
Operating System: Windows 10

Re: Enhancement for Macros

Post by mafg1953 » Sat Nov 07, 2020 10:59 pm

Steve,

That approach would be great for stepping through and troubleshooting a Macro! I would welcome that as a solution to the suggestion I brought up!

I don't want to push my luck, but as long as your in the "Macro mood", ..... maybe the ability to create a copy of a Macro. That way when troubleshooting, you could keep the original and have a working copy to play with.

If I want a copy now, I go to the Macro folder and copy the Macro I want to work on to a new name. That works fine, but I need to exit Audacity, go to the folder, copy and rename the Macro, and then re-start Audacity. Not a big deal, but a copy button, or a copy Macro plug-in would be helpful.

Thanks again for the quick feedback.

Mike

steve
Site Admin
Posts: 81229
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Enhancement for Macros

Post by steve » Sun Nov 08, 2020 9:20 am

mafg1953 wrote:
Sat Nov 07, 2020 10:59 pm
That approach would be great for stepping through and troubleshooting a Macro! I would welcome that as a solution to the suggestion I brought up!
Unfortunately I overlooked a problem, so there is a limitation.

"Ctrl+R" will repeat the last "Effect", but it only works for "Effects" and not "Tools" (or Generators or Analyze plug-ins).

"Effect" type plug-ins require an audio selection, otherwise you just get an error message telling you to make a selection.

Macros do not require an audio selection, and some Macros may contain one or more steps where there is no selection.

A possible workaround would be if I make this a "Tool" type plug-in, but then you would need to create a custom shortcut rather than "Ctrl+R". (I've not tried that yet).
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81229
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Enhancement for Macros

Post by steve » Sun Nov 08, 2020 9:26 am

mafg1953 wrote:
Sat Nov 07, 2020 10:59 pm
I don't want to push my luck, but as long as your in the "Macro mood", ..... maybe the ability to create a copy of a Macro. That way when troubleshooting, you could keep the original and have a working copy to play with.

If I want a copy now, I go to the Macro folder and copy the Macro I want to work on to a new name. That works fine, but I need to exit Audacity, go to the folder, copy and rename the Macro, and then re-start Audacity. Not a big deal, but a copy button, or a copy Macro plug-in would be helpful.
The next version of Audacity will have "Import" and "Export" buttons.
Until then, just manually copy the files in:
Users\<username>\AppData\Roaming\audacity\Macros\
as you are doing now.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81229
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Enhancement for Macros

Post by steve » Sun Nov 08, 2020 1:34 pm

steve wrote:
Sun Nov 08, 2020 9:20 am
A possible workaround would be if I make this a "Tool" type plug-in, but then you would need to create a custom shortcut rather than "Ctrl+R". (I've not tried that yet).
Here's the plug-in:
MacroStepThrough.ny
(1.38 KiB) Downloaded 31 times
When installed it will appear in the Tools menu.

The way that I'm using it is to set a keyboard shortcut ("Ctrl + \", but for no other reason than it's available).
To step through requires two key pressess: "Ctrl + \" then "Enter".

On completion of the Macro, the plug-in automatically resets.
To force a reset before the Macro has completed, either enter an invalid Macro name, or leave the Macro name empty.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply