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

Re: Enhancement for Macros

Post by mafg1953 » Sun Mar 21, 2021 1:24 pm

Steve,

I was working on a macro to take the pause in an audio file (that occurs between a talk and the q/a section or between particular questions and answers) and replace it with a fixed length of room tone and at the same time do a fade-out on the leading audio with a fade-in on the trailing audio. That way all my transitions are consistent.

I was using your MacroStepThrough tool to test the various steps and noticed that if I am using Fade + for the fading that the MacroStepThrough did not perform that step but it was performed in the actual execution of the Macro. The same is true with a Punch-Paste step I have in the Macro using room tone in the fixed clipboard. If I replace the Fade + with Fade-In or Fade-Out and if I replace the Punch-Paste with a Silence-Audio command, all those effects do show up when I do a MacroStepThrough.

I'm wondering if maybe the MacroStepThrough treats Nyquist commands differently than other internal commands.

It's not a big deal as I'm sure you have plenty of other things to work on. Just thought I would check.

Thanks,

Mike

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

Re: Enhancement for Macros

Post by steve » Sun Mar 21, 2021 3:18 pm

mafg1953 wrote:
Sun Mar 21, 2021 1:24 pm
I'm wondering if maybe the MacroStepThrough treats Nyquist commands differently than other internal commands.
Yes it does. This is a limitation of running macro commands from Nyquist - you can't run a Nyquist plug-in from a Nyquist plug-in.

For example:
You can run the normal "Fade In" or "Fade Out" effects from Nyquist, and you can run a macro that contains "Fade In" or "Fade Out" from Nyquist,
but,
You cannot run "Studio Fade" or "Adjustable Fade" (both of which are Nyquist effects) from Nyquist, and you cannot run a macro that contains "Studio Fade" or "Adjustable Fade" from Nyquist. In this case the "Studio Fade" or "Adjustable Fade" step will silently fail.

Unfortunately there is currently no way round this limitation.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Enhancement for Macros

Post by steve » Sun Mar 21, 2021 3:45 pm

A new version of "Macro Step Through".
Unfortunately it still has the same limitation as described in my previous post (Nyquist effects don't run), but it has some additional "Actions".
  • Step: This is the normal step-through mode. Performs one step of a macro.
    Each time this runs it automatically moves onto the next command in the macro.
  • Restart: Resets and runs the first step of the macro.
    You would normally run this once only and then change to the normal "Step" action.
  • Skip Step: Skips one command step and runs the next one.
  • Repeat Step: Runs the last step again.
  • Run All: Runs the entire macro from start to end.
    (as always, any Nyquist effects in the macro fail silently)
  • Reset: Reset (only).
Note that as with all Nyquist effects, it defaults to the last selected settings, so, for example, if you run "Action: Reset", then repeating "Macro Step Trough" will simply reset again. To go back to stepping through a macro you need to run it with the GUI and select "Action: Step".
MacroStepThrough.ny
(2.31 KiB) Downloaded 29 times
Feedback and bug reports welcome.
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 » Wed Mar 24, 2021 12:50 am

steve wrote:
Sun Mar 21, 2021 3:45 pm
A new version of "Macro Step Through".
MacroStepThrough.ny
Feedback and bug reports welcome.
Steve,

Thanks for this update - it will definitely come in handy.

I was testing a simple macro that has three steps:
  • select 0-5 minutes
  • select 5-10 minutes
  • select 10-15 minutes
When I start the macro and select skip step, the macro executes the third step but I'm expecting it to skip over the first step and execute step 2, i.e., select 5-10 minutes.

If I'm about to execute step 2 and select skip step, it does go to step three. So maybe there is a glitch at the first step?

Also, it would be nice to have a counter in the dialog box that indicates which step of the macro was either just executed or will be executed next - especially for longer macros. I guess that might be a bit complicated to program if you are using repeat and skip a lot.

Thanks,

Mike

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

Re: Enhancement for Macros

Post by steve » Wed Mar 24, 2021 10:06 am

mafg1953 wrote:
Wed Mar 24, 2021 12:50 am
So maybe there is a glitch at the first step?
I've probably used a count starting from 0 in one place, and starting from 1 in another.
Should be an easy fix.

mafg1953 wrote:
Wed Mar 24, 2021 12:50 am
Also, it would be nice to have a counter in the dialog box that indicates which step of the macro was either just executed or will be executed next - especially for longer macros.
I considered that, but it could be annoying, or at least slower if you have to dismiss a message dialog after each step:
_____________
Executed step 1
of "My Test Macro".
____[OK]____


I guess there could be an option in the GUI:
Display Step Number: (choice) [Yes | No]
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 » Wed Mar 24, 2021 11:12 am

steve wrote:
Wed Mar 24, 2021 10:06 am
I considered that, but it could be annoying, or at least slower if you have to dismiss a message dialog after each step:
_____________
Executed step 1
of "My Test Macro".
____[OK]____


I guess there could be an option in the GUI:
Display Step Number: (choice) [Yes | No]
Steve, or could it just be a notification that says "Step 1 Executed" without needing a reply?

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

Re: Enhancement for Macros

Post by steve » Wed Mar 24, 2021 12:01 pm

mafg1953 wrote:
Wed Mar 24, 2021 11:12 am
or could it just be a notification that says "Step 1 Executed" without needing a reply?
If it's a pop-up window displaying a result from the Nyquist plug-in, then it has to be dismissed before you can do anything else.
Try this in the Nyquist Prompt:

Code: Select all

(print "I am a message window.")
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 » Wed Mar 24, 2021 1:01 pm

steve wrote:
Wed Mar 24, 2021 12:01 pm
mafg1953 wrote:
Wed Mar 24, 2021 11:12 am
or could it just be a notification that says "Step 1 Executed" without needing a reply?
If it's a pop-up window displaying a result from the Nyquist plug-in, then it has to be dismissed before you can do anything else.
Try this in the Nyquist Prompt:

Code: Select all

(print "I am a message window.")
Could it be a part of the "Action (Step XX):" or even part of the title of the dialog - "Macro Step Through - Step XX"?

Capture.JPG
Capture.JPG (24.77 KiB) Viewed 886 times

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

Re: Enhancement for Macros

Post by steve » Wed Mar 24, 2021 3:06 pm

mafg1953 wrote:
Wed Mar 24, 2021 1:01 pm
Could it be a part of the "Action (Step XX):" or even part of the title of the dialog - "Macro Step Through - Step XX"?
The available GUI options for Nyquist plug-ins are quite limited.

The interface is created on the fly by Audacity before the Nyquist code runs.
The plug-in code only knows which line of the file it is on when the code runs.
so it is not possible for the plug-in code to modify the GUI in any way.

Something that I'd like to see in the future is the ability for the plug-in code to define the GUI. On launching a Nyquist effect, part of the Nyquist code runs first to create the GUI, then on clicking "OK" the effect itself runs. We don't have this yet.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Enhancement for Macros

Post by steve » Wed Mar 24, 2021 4:48 pm

Possible solution - I could print the line number to the debug output.

The debug output is visible in one of two ways:

1. Run the effect with the "Debug" button (rather than the "OK" button).
2. Run the effect with the "OK" button and look in the Audacity log window.

I expect that the Audacity log window would normally be preferable as you can open it (from "Help menu > Diagnostics > Show Log") and leave it open while using Audacity.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply