Create a Macro with a infinite loop

Hello all,

First of all, thank you all developers and contributors of Audacity. It is been very helpfull for many people that needs to do recordings and editings.

My question is: It is possible to create a Macro or Nyquist plugin that keep runing in the background?
Aplication: I would like to create a kind of backup system that would export a wav file of the project each certain amount of time. It was simple to script .wav exportation (AUD-DO “ExportWav”), but I would like to have it running automatically from time to time. It would be fine if the user needs to trigger to start “backuping”.

Thanks for any help.
Rafa

No, not with normal Macros or Nyquist, but you can with Python.

With Python you can use very similar commands. Rather than (AUD-DO “ExportWav”), you can simply send the string “ExportWav” to Audacity via a named pipe.

More information here: Scripting - Audacity Manual

If you are at all familiar with Python, the easiest way to get started is with the pipeclient.py module (see: https://github.com/audacity/audacity/blob/master/scripts/piped-work/pipeclient.py)

Hi Steve,

Thank you for your help. I was trying to avoid going to mod-script-pipe but it seems to be the only way to do it.

Rafa

Is that because you don’t know Python?

No, I’m concerned about this phrase on documentation:

If you use mod-script-pipe to enable scripting, this weakens computer security, as malicious software that already has a foothold on your computer could potentially use this feature to gain more control.

Since it would be used on a Interprise solution, I don’t feel confortable weakening the security of the computers. We could analyze the risks and see if it worth.

This is why I was triyng to avoid going to this direction.

Rafa

That “risk” only applies while Audacity is running with mod-script-pipe enabled. As far as I’m aware, it only applies in multi-user situations (where more than one user has access to the computer at the same time). For a typical single user computer, then the risk only occurs if your computer has already been hacked and someone else is able to access it.

The security risk is that commands sent to Audacity via the named pipe are not filtered. This presents an attack vector for anyone that has access to the computer. For example, if your computer is on a network, and someone else on the network can gain access to your temp folder, then it is theoretically possible for them to send specially crafted malicious commands to Audacity via the named pipe.

If your computer is networked, then you could disconnect from the network before enabling mod-script-pipe, and disable mod-script-pipe before going back on the network.

If your computer is not accessible from outside, and there is only one user at a time on the computer, then it’s not a problem.


Having said that, there is a problem with your idea of triggering an automatic backup. Scripting commands bypass the normal GUI methods for entering commands. When using a normal Macro, normal GUI commands are disabled while the script is running. That is not the case when sending commands from Python. If a “Save” command was sent from Python while Audacity is busy doing something else, the result is undefined. I’ve not tested but I’d not be surprised if it caused Audacity to crash and corrupt the project data.

I think a much safer approach would be to write a one button click backup script which you could then manually trigger at any suitable time.

Thanks steve for your explanation. Here are some thoughts.

That would not work for us since our users use others programs that are network dependents. Also we are studying a posibility to do audio recording directly to network drivers.

We will weight the pro and contras of having this feature, specialy when it could crash Audacity.

Yes. We might go to this direction.

Thanks for all support.
Rafa

Audacity is probably not your best choice for using across a network. Audacity expects low latency read / write access to it’s data. It has no provision for handling lost packets, and uses small audio buffers which are not sufficient to handle network delays.

There are some things you can safely do with Audacity across a network, but it is highly recommended to retain project data on a local drive.

  • Mod-script-pipe should NOT be used on a network unless you can guarantee that it is a secure private network (see security warning).
  • With a suitable sound server (such as RTP, SIP), and a sufficiently fast network, it is possible to stream audio for recording / playback.
  • Network drives can be useful for storing backup data (Audio files or “Lossless compressed projects” are preferable to ordinary projects).

Guys,

Just to post a update on what was the end of this subject on our side.
We end up creating a python script that does the backup every certain amount of time. It checks the modification date of the opened project and compare to the latest backup. If they are different, it will backup the aup file and the au files needed maintaining the same structure (We are modifying the prjname tag on aup to point to the new data folder) If the AU files needed for this project were backed up already, it copies just the new ones. It is not different from others backup programs, like Duplicati, but this script fits better ours needs.

Feel free to close this topic if you want to.

Rafa

Thanks for reporting back Rafa - glad you got it sorted

Peter.