Closing the project from macro

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
Msv264
Posts: 13
Joined: Mon Apr 05, 2021 8:08 pm
Operating System: Windows 8 or 8.1

Closing the project from macro

Post by Msv264 » Mon Apr 05, 2021 8:55 pm

Hello.
I'm trying to close the current project from macro script. Is it possible? There is no such command in the "insert command" list in macro dialog.
When i have added command "close" into macro script manually (in txt file), the Audacity crashed.
I'm trying to process a number of audacity aup3 projects. First I tried to use the option "files" in macro dialog - but it doesn't work. It seems this way you can process only external files like mp3.
Now I'm trying in one long macro process several projects. I can open project, do processing, but can't close it to open and process another one.
Maybe I' wrong and there is more simple way.
I wiil be really glad for any suggestions.

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

Re: Closing the project from macro

Post by steve » Mon Apr 05, 2021 9:26 pm

Msv264 wrote:
Mon Apr 05, 2021 8:55 pm
When i have added command "close" into macro script manually (in txt file), the Audacity crashed.
I don't think it can be done in a Macro, at least not without crashing, because the macro is running as the current project and cannot complete if the project is closed.
You can create a new project with a macro, but that macro can't do anything in the new project because it's a different project. When a macro runs, it is acting on the project in which it was opened.
Msv264 wrote:
Mon Apr 05, 2021 8:55 pm
I wiil be really glad for any suggestions.
I think the only way that you could do this is from an external programming language (such as Python). See: https://manual.audacityteam.org/man/scripting.html
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

waxcylinder
Forum Staff
Posts: 14658
Joined: Tue Jul 31, 2007 11:03 am
Operating System: Windows 10

Re: Closing the project from macro

Post by waxcylinder » Tue Apr 06, 2021 11:11 am

I don't think it can be done in a Macro, at least not without crashing, because the macro is running as the current project and cannot complete if the project is closed.
I just tested (on W10 with latest 3.0.1 alpha), and:

a) there is an Exit command available to Macros
b) It will exit and close Audacity
c) you will need to Save Project in the Macro first to a unique unused name - as otherwise you get the saving dialog
d) you'll need to use the Save Project2 unless you carefully delete any pre-existing project that may be overwritten - as otherwise you'll bet the overwrite warning dialog

Peter
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * FAQ * * * * * Tutorials * * * * * Audacity Manual * * * * *

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

Re: Closing the project from macro

Post by steve » Tue Apr 06, 2021 11:17 am

waxcylinder wrote:
Tue Apr 06, 2021 11:11 am
a) there is an Exit command available to Macros
b) It will exit and close Audacity
c) you will need to Save Project first to a unique unused name - as otherwise you get the saving dialog
d) you'll need to use the Save Project 2 unless you carefully delete any pre-existing project that may be overwritten - as otherwise you'll bet the overwrite warning dialog
That illustrates the problem clearly. The macro cannot continue after the "Exit:" command.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

waxcylinder
Forum Staff
Posts: 14658
Joined: Tue Jul 31, 2007 11:03 am
Operating System: Windows 10

Re: Closing the project from macro

Post by waxcylinder » Tue Apr 06, 2021 11:20 am

steve wrote:
Tue Apr 06, 2021 11:17 am
The macro cannot continue after the Exit: command.
Which begs the question: why, them, do we have an Exit command available to Macros? :? :roll:

Peter
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * FAQ * * * * * Tutorials * * * * * Audacity Manual * * * * *

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

Re: Closing the project from macro

Post by steve » Tue Apr 06, 2021 11:22 am

waxcylinder wrote:
Tue Apr 06, 2021 11:20 am
Which begs the question: why, them, do we have an Exit command available to Macros?
So that you can tell Audacity to exit when the macro has completed (could be useful for macros that take a very long time to complete).
In other words, the "Exit" command can be useful as the final command in a macro.

The problem for Msv264 is that they want to run a macro on multiple projects, but the "context" for a macro is the project in which it is running.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

waxcylinder
Forum Staff
Posts: 14658
Joined: Tue Jul 31, 2007 11:03 am
Operating System: Windows 10

Re: Closing the project from macro

Post by waxcylinder » Tue Apr 06, 2021 11:28 am

steve wrote:
Tue Apr 06, 2021 11:22 am
The problem for Msv264 is that they want to run a macro on multiple projects, but the "context" for a macro is the project in which it is running.
Isn't that what we have apply Macro to files for ?
https://manual.audacityteam.org/man/app ... html#files

Peter
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * FAQ * * * * * Tutorials * * * * * Audacity Manual * * * * *

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

Re: Closing the project from macro

Post by steve » Tue Apr 06, 2021 11:31 am

waxcylinder wrote:
Tue Apr 06, 2021 11:28 am
Isn't that what we have apply Macro to files for ?
No. That's for applying a macro to multiple audio files.
Msv264 wants to apply a macro to multiple Audacity projects, and as far as I'm aware, that can't be done with a macro.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Msv264
Posts: 13
Joined: Mon Apr 05, 2021 8:08 pm
Operating System: Windows 8 or 8.1

Re: Closing the project from macro

Post by Msv264 » Tue Apr 06, 2021 8:48 pm

In fact, it's really strange - you can do batch processing for an audio files, but can't do the same for an Audacity projects.
My situation is really simple - I've got a lot of records, made in Audacity, and wish to process them with a set of effects - declick, decracle, debreath, equalizer, denoise, etc.
On the way I would like to make a backup copy.
It takes a lot of time, and it is completely not interesting to sit near computer and wait until it finishes one project to start processing the next one.
I think, the batch processing was invented especially for the situations like this.
Another strange question - why there is an Open project command in the macro command list? What for?

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

Re: Closing the project from macro

Post by steve » Tue Apr 06, 2021 9:24 pm

Msv264 wrote:
Tue Apr 06, 2021 8:48 pm
Another strange question - why there is an Open project command in the macro command list? What for?
It's probably not very useful for using in Macros, but the commands are not only for Macros. They are also for controlling Audacity from an external applications (see: https://manual.audacityteam.org/man/scripting.html) and from Audacity's built-in scripting language "Nyquist" (see: https://manual.audacityteam.org/man/nyquist_macros.html). The commands belong to an API (application programming interface) that can be used in multiple ways.

Macros can be seen as a very simple form of programming. An Audacity macro is just a list of commands that runs within the context of an Audacity project.

Python scripting is more flexible as it runs outside of Audacity and has control structures that allow looping, conditional statements, and everything else that comes with a full-featured programming language (it is also more complicated).


Msv264 wrote:
Tue Apr 06, 2021 8:48 pm
I think, the batch processing was invented especially for the situations like this.
No. The batch process was invented especially for applying the same processes to multiple audio files.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply