Clicking Enter as part of a 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
joedale
Posts: 11
Joined: Wed Jun 02, 2021 1:02 pm
Operating System: Windows 10

Clicking Enter as part of a macro

Post by joedale » Wed Jun 02, 2021 1:06 pm

Hi everyone,

I’m a big fan of Audacity’s Punch Copy/Paste and Punch Paste plug-ins for using room tone for removing pops, lip smacks, bumps, ums and arrs etc from a track.
viewtopic.php?t=71556

When I record double enders, I click my fingers three times at the start so three spikes appear in my Audacity track. My interviewee / co-host are then silent for 10 seconds to record their own room tone on their own local track and then when we’ve finished everyone sends me their track and I sync them together in Audacity using the Zoom ‘scratch’ track I import as a guide as it also contains the three spikes. Having everyone’s room tone is invaluable when multi-track editing and keeping everything in sync. Normally, when I want to replace a mistake with some room tone on a track, I create a label, go to the start of that track, select 5 seconds of room tone and press Shift + O plus Enter twice. I then go back to the label, select the mistake and press Shift + P.

Today I put together a two part macro to make the copying of room tone quicker and return to the part of a track in a multi-track session where I wanted to replace the mistake. Here are the different steps:

Punch Copy Paste Part 1
01 Move focused Track to Top
02 Store Selection
03 Cursor to Project Start
04 Select (Start 0 End 5)
05 Punch Copy / Paste
06 END

Punch Copy Paste Part 2
01 Retrieve Selection
02 END

I wasn’t able to work out how to click OK as part of the macro once the 5 seconds of room tone had been copied. I just had to click Enter manually which is why I had to make two macros. I’ve also used Shift + Ctrl + O as a hot key for the first macro and Shift + Ctrl + P for the second one to save more time when editing.

The two macros do work as I wanted which is great and they were fun to put together. I’d really appreciate any feedback particularly if you know how to automatically press Enter as part of a macro.

Thank you for your time.

Best wishes

Joe

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

Re: Clicking Enter as part of a macro

Post by steve » Wed Jun 02, 2021 1:29 pm

"Punch Copy" won't work in a macro. You will have to do that bit manually.
This effect is unusual in that I had to trick Nyquist into retaining the audio data after the effect has completed. The message that has to be manually dismissed by clicking "OK", is part of that "trick". Without that, the trick does not work and Nyquist will automatically free up the RAM used by the effect, which leaves the clipboard empty.

"Punch Paste" can be used in a macro.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Clicking Enter as part of a macro

Post by steve » Wed Jun 02, 2021 1:35 pm

steve wrote:
Wed Jun 02, 2021 1:29 pm
"Punch Copy" won't work in a macro. You will have to do that bit manually.
This effect is unusual in that I had to trick Nyquist into retaining the audio data after the effect has completed. The message that has to be manually dismissed by clicking "OK", is part of that "trick". Without that, the trick does not work and Nyquist will automatically free up the RAM used by the effect, which leaves the clipboard empty.
Looking at this again, I think there may be a way to get this to work in Audacity 3.0.2 ....

I'll do some experiments :ugeek:
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

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

Re: Clicking Enter as part of a macro

Post by steve » Wed Jun 02, 2021 2:12 pm

This may not be the final version, but try replacing your current version of "PunchCopy.ny" with this version.

This version has an additional option in "Select Action":
  • Copy (safe): Copies the selected audio to the clipboard only if the plug-in's clipboard is empty.
  • Copy (replace): Copies the selected audio to the clipboard. Any audio currently on the clipboard will be discarded.
  • Copy (silent): Same as "Copy (replace)" but all messages are suppressed. This is intended to allow the effect to be used in macros. In the event of errors, look in Audacity's "Help menu > Diagnostics > Show Log" for info or possible error messages.
  • Paste: Pastes the contents of the clipboard, using the paste settings.
  • Clear: Clears the clipboard.
Please give all options a good test, and let me know if there are any problems.
PunchCopy.ny
(10.03 KiB) Downloaded 10 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

joedale
Posts: 11
Joined: Wed Jun 02, 2021 1:02 pm
Operating System: Windows 10

Re: Clicking Enter as part of a macro

Post by joedale » Wed Jun 02, 2021 2:33 pm

Hi Steve,

Thank you for your prompt reply. How can I access the new version of the plugin with Copy (Silent) and what would the new steps be in the macro? Would I still be able to use Punch Copy/Paste and Punch Paste as before if I use the new version?

Best wishes

Joe

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

Re: Clicking Enter as part of a macro

Post by steve » Wed Jun 02, 2021 2:39 pm

joedale wrote:
Wed Jun 02, 2021 2:33 pm
How can I access the new version of the plugin with Copy (Silent)
Oops, sorry, I forgot to attach it to my previous post. :oops:
It's there now.
joedale wrote:
Wed Jun 02, 2021 2:33 pm
Would I still be able to use Punch Copy/Paste and Punch Paste as before if I use the new version?
Yes, everything else should work as before, but now that you are involved in "software development" (as an official tester) ;) give the new plug-in a thorough work-out and see if you can find anything that fails to work as it should. (This is known as the "see if I can break it" test).
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

joedale
Posts: 11
Joined: Wed Jun 02, 2021 1:02 pm
Operating System: Windows 10

Re: Clicking Enter as part of a macro

Post by joedale » Wed Jun 02, 2021 3:11 pm

Hi Steve,

I've tried out the new version and when I run the macro with Copy (Silent) selected, it no longer requires me to click Enter which is great. I have to manually click on the track where I want to drag and make a selection though instead of the cursor going there automatically with the Retrieve Selection command. When I select an area to be replaced and run Punch Paste it does paste the room tone from the start of the track so it's working, but why when I add Retrieve Selection into the macro, the cursor stays at the beginning of the track? Any ideas why?

Best wishes

Joe

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

Re: Clicking Enter as part of a macro

Post by steve » Wed Jun 02, 2021 5:05 pm

I think I can see the problem, but please post your macro (export the macro and then copy / paste from the exported file into your reply) so that I can test it.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

joedale
Posts: 11
Joined: Wed Jun 02, 2021 1:02 pm
Operating System: Windows 10

Re: Clicking Enter as part of a macro

Post by joedale » Wed Jun 02, 2021 5:45 pm

Here is the first macro:

TrackMoveTop:
SelSave:
CursProjectStart:
Select:End="5" Mode="Set" Start="0"
PunchCopy/paste:curve="Linear" fade-seconds="0" loop="Enable looping" mix="100" mode="Copy (silent)"

Here is the second:

SelRestore:

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

Re: Clicking Enter as part of a macro

Post by steve » Wed Jun 02, 2021 6:05 pm

joedale wrote:
Wed Jun 02, 2021 5:45 pm
TrackMoveTop:
You need to be a bit careful with that command because it's possible for the "selected track" and the "track with focus" to be different. The results can be unexpected if you're not aware of that.

You may know this already, but just in case, here's an example:

1. Create a project containing two audio tracks.
2. Click on the "Select" button to select the first track.
3. Press the "cursor down" key.
4. Observe that the first track is still selected, but the second track has the yellow border, indicating that the second track "has focus" (is the current track that will be acted on by "TrackMoveTop:")

joedale wrote:
Wed Jun 02, 2021 5:45 pm
TrackMoveTop:
SelSave:
CursProjectStart:
Select:End="5" Mode="Set" Start="0"
PunchCopy/paste:curve="Linear" fade-seconds="0" loop="Enable looping" mix="100" mode="Copy (silent)"

Here is the second:

SelRestore:
I assume that ideally you would like to be able to merge the two macros so that PunchCopy grabs the first 5 seconds, and then pastes it into the original selection. Is that the idea?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply