Clicking Enter as part of a macro

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.
https://forum.audacityteam.org/t/punch-copy-paste/28906/1

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

“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.

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:

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 KB)

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

Oops, sorry, I forgot to attach it to my previous post. :blush:
It’s there now.

Yes, everything else should work as before, but now that you are involved in “software development” (as an official tester) :wink: 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).

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

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.

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:

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:”)


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?

Hi Steve,

Thank you so much for your help so far. Yes that’s the idea to have one macro which works on any track in a multi-track session.

Best wishes

Joe

Yes, that’s right Steve. Ideally I would like to be able to click near the section I want to replace with room tone, run the macro which will then grab the 5 seconds of room tone at the beginning of the track, put the cursor back in the same position as before the macro was run so I can select the error and use the hot key to run Punch Paste. It would be great to do this with one macro rather than two.

Best wishes

Joe

To avoid problems with the new version (which I’ll post shortly), you should reset Audacity’s effects.
To do that:

  1. Ensure that Audacity is not running.
  2. Open the hidden folder: *Users__\AppData\Roaming\audacity*
    (where “” is your computer log-in name).
  3. Delete these two files:
    pluginregistry.cfg
    pluginsettings.cfg

Then go to: Users**\AppData\Roaming\audacity\Plug-Ins** and delete “PunchCopy.ny” and “PunchPaste.ny”.

After that you will need to re-enable any custom plug-ins that you have installed (they will be listed as “New” plug-ins in the Plug-in Manager).

Here’s the macro that I’ve tested with:
PunchCopyPaste.txt (215 Bytes)
and here are the new plug-ins:
PunchPaste.ny (6.21 KB)
PunchCopyPaste.ny (10.1 KB)

Hi Steve,

I downloaded both the new plugins and enabled them, but they are not appearing in the effects menu. Shift O and Shift P are still working to enable Punch Copy/Paste and Punch Paste. I imported the txt file for the macro, but when I ran it, it selected both tracks and cleared them / replaced them with room tone. Any idea what the issues are?

Best wishes

Joe

Hi Steve,

I’ve just noticed that the Punch Copy/Paste and Punch Paste are now in the Tools menu. What have I done wrong?

Best wishes

Joe

That’s correct. Is that a problem?

Hi Steve,

I was just surprised to see the Punch Copy/Paste and Punch Paste plug-ins in the Tools menu as they’ve always been in the Effects menu. Are all new custom plug-ins placed in the Tools menu in 3.0.2? I’ve removed the Punch Paste step from the macro by the way and it’s working how I wanted it so thank you so much!

Just another thought, would it be possible to select a mistake in a track, run a similar macro and have the mistake replaced with room tone taken from the first five seconds of the track? That would require fewer clicks if possible. I really appreciate all your help today by the way.

Best wishes

Joe

I should have mentioned that change. Pleased that you found it, and hope that it did not cause you too much bother.
I also updated the code to the current version.

No. Usually:

  • Plug-ins that process the selected audio are in the “Effect” menu.
  • Plug-ins that generate audio are in the “Generate” menu.
  • Plug-ins that analyze the selected audio are in the “Analyze” menu.
  • Other plug-ins that are not of the above three types are in the “Tools” menu.

These two plug-ins are sort of “Edit” type, but we can’t put plug-ins in the “Edit” menu, so the “Tools” menu seemed to me like the best option.


The plug-ins and macro are not fussy what audio you select. Whatever you select, when you run the macro, it will replace the selected audio with audio from the first 5 seconds of the track.
Note also that if the first 5 seconds is not “silence”, the plug-ins and macro don’t care about that either. They will paste whatever is in the first 5 seconds.

Have fun, and let me know how you get on.
In particular, let me know if you find any bugs in the new effects (I’ve done some testing, but I didn’t want to keep you waiting too long :wink:)

Hi Steve,

I’ve just re-added the Punch Paste element into the macro and ran it having made a selection and it replaced it with room tone e.g. from the first five seconds of the track. Thank you so much. This is going to save me hours! Really, really appreciate your expertise and advice.

Best wishes

Joe