Punch Copy/Paste

A pair of plug-ins for simplifying “punch in” editing.
Unlike the standard paste function in Audacity, the “punch” paste replaces the selected audio with just the right amount of pasted audio to match the duration of audio being replaced, thus the speed and timing of the track is not changed by pasting.

These plug-ins were developed from a feature request on the forum (https://forum.audacityteam.org/t/alternate-equal-length-paste-command-resolved/28836/1) to streamline the work flow of replacing parts of a track with “room noise” (ambient noise), though in its current form it could have many other uses.

The first plug-in is called “Punch Copy” and the second is called “Punch Paste”.
“Punch Copy” can be used on its own, but “Punch Paste” can only be used after using “Punch Copy”.

Punch Copy:
The default action of this plug-in is to copy the selected audio to its own clipboard (which is independent from the normal Audacity clipboard). The “clipboard” contents are held in RAM so it is essential that there is sufficient free RAM available to copy the selected audio. It also sets the parameters (settings) for the Punch Paste effect.

  • Select action: [Copy (default), Paste, Clear Clipboard]
    Copy will copy the selected audio to the clipboard.
    Paste will paste the current “Punch” clipboard into the current selection.
    Clear Clipboard empties the “Punch” Clipboard and frees the computer memory that was used for storing the clipboard.
  • Paste: Loop mode: [Looping (default), Single Shot]
    This sets how paste will behave if pasting into a selection that is longer than the clipboard contents.
    When “Looping” is selected, the clipboard will be repeated as many times as necessary to fill the current selection.
    When “Single Shot” is selected, the clipboard contents are pasted once only at the start of the selection.
    Note that if the clipboard contents are “looped” there is no crossfade between each repeat.
  • Crossfade type: {Linear (default), S-Curve, Eq Power]
    When the crossfade time is greater than zero, the start and end of the paste will crossfade with the original track audio. This is useful for producing a smooth transition between the original audio and the pasted audio.
    Three types of crossfade are available:
  1. Linear (default): Recommended for very short crossfades (when the crssfade is just a few milliseconds). The maximum amplitude after pasting will not be greater than the higher of the clipboard contents or the original audio (which means that provided that neither the audio on the clipboard, or the track being pasted into are clipped, then the result of pasting will not clip).
  2. S-Curve: This provides a smooth, low distortion crossfade. The maximum amplitude after pasting will not be greater than the higher of the clipboard contents or the original audio. This is recommended for longer crossfades where it is important that the resulting amplitude is not higher than the source audio (the clipboard and the destination track).
  3. Eq Power: This is recommended to maintain a constant perceived loudness across the crossfade transition. It is particularly effective when pasting ambient noise into similar audio. Note that the resulting audio may have a higher peak level than both the clipboard audio and the selection contents, so take care with this option if either of these have a high peak level.
  • Max crossfade time (s): [slider range, 0 to 5 seconds, default 0]
    When set to zero, the audio will be pasted without any crossfade. When set above zero, this will set the time taken to fade from the original selection content to the pasted clipboard content, and from the pasted clipboard content back to the original selection audio. If the crossfade time is too long to fit into the selection, then the actual crossfade time will be half of the selection length, so that the pasted content will fade in and then immediately begin to fade out.

When Punch Copy is used, the “paste” options are stored on the clipboard along with the copied audio.
Note that the settings are stored on the clipboard whether “Punch Copy” is being used to copy or paste.
The settings are cleared when the clipboard is cleared.

Punch Paste:
This plug-in is a “one click” effect with no user interface. It takes its settings from whatever was set the last time that Punch Copy was used (within the current Audacity session). Thus the defaults are the same as for Punch Copy. Obviously, before Punch Paste can be used it is necessary to use Punch Copy so that there is some audio on the clipboard.

The benefit of a separate “Punch Paste” plug-in is that allows the same clipboard content to be pasted multiple times quickly and easily. The most efficient way to paste the clipboard contents is to set a keyboard shortcut to the Punch Paste effect.

Because Punch Paste has no user interface, the only way to change the paste settings is to use the Punch Copy effect (in either “Copy” mode or “Paste” mode).

Mono / Stereo
The plug-ins support both mono and stereo.
When pasting mono audio from the clipboard into a stereo track, the clipboard is pasted into both left and right channels.
When pasting stereo audio into a mono track, the clipboard contents are mixed to mono before pasting (though the clipboard contents remain unaltered so it can still be pasted as stereo into a stereo track).


  • The effect can be quite slow when pasting into a large selection.
  • Only one audio clip can be stored on the clipboard at one time.
    Attempting to copy multiple selected tracks at the same time will copy each track in turn, overwriting the previously copied selection, so that only the selection from the last audio track remains on the clipboard.
  • The maximum duration of audio that can be copied is 100 million samples.

Do not attempt to copy a large selection if your computer does not have sufficient RAM - doing so will probably cause Audacity to crash.
1 minute of stereo audio at CD quality will use around 20 MB of RAM (memory). A 20 minute selection will use around 400 MB of RAM.
Pasting the clipboard does not clear this RAM (so the same clipboard may be pasted multiple times). Use the “Clear Clipboard” option to empty the clipboard and release the used memory.
PunchCopy.ny (8.45 KB)
PunchPaste.ny (5.58 KB)
Current Version:PunchCopy.ny (9.8 KB)
Current Version: PunchPaste.ny (6.2 KB)

For a new version that is compatible with macros in Audacity 3.0.2, see: https://forum.audacityteam.org/viewtopic.php?p=427085#p427085

Very nice. So I think this meets the Audacity feature request for “Paste Fill” http://wiki.audacityteam.org/wiki/Feature_Requests#paste ?

“Before” and “Mix” suggested in that link would also be very useful. I’m not sure what “Replace” means there if it doesn’t mean “Fill”.

If you haven’t noticed yet, both effect names start with “Puch”, and “Puch Paste” has a typo “Pasteing data…” for the “action”. As this isn’t really a replacement for “punch-in recording” my current thought is that “Paste Fill” would be a much more descriptive name.

I was confused when I pasted an hour of audio with Punch Copy that the progress dialogue said “Copying data…”, so maybe the action should be “Copying or Pasting data as requested…” or somesuch.

“Paste:Loop Mode” and its choices doesn’t look very user-friendly. Perhaps “Pasting when clipboard too short: Repeat, Paste Once” or somesuch?

I copied several times with Punch Copy when really intending to paste with a different “looping” action. This is obviously a pain if you can no longer access what you put on the punch clipboard. If it was a built-in effect I guess changing the paste method would change the effect action to “Paste”.

On reflection I think as a user I would rather have “Select actions” in the first box “Paste (repeat)” and “Paste (once)” or similar (so do away with the “Paste:Loop mode” control) than lose my punch clipboard. I know this makes it harder to label “Select action” - maybe “Select action/type of paste”? Or looked at another way, repeat is surely the obvious action - “repeat” does the “fill” when the selection is too long. The actions could be “Fill, Paste once”.

I thought it could occasionally be useful to copy the punch clipboard to the Audacity clipboard or even vice-versa (these could be useful to counter overwriting the punch clipboard in error).


It amazes me that I can spot a missing “)” at 50 paces, but I can be staring at misspelling for a week and not see it at all. Fixed now,

Yes I think it does (though it is not available in the Edit menu, which I think was the intention in that request).

I’m not sure what the “Before/After” suggestions are about - do they mean “Insert at the start/end of the selection”? If so, I’m not convinced by how useful they would be - surely you would just click and paste rather than “Select → Paste > Special > Before”?

I can see “Mix paste” being useful, particularly with a “% mix” option. I’ll look at working that in.

No it isn’t, but it is a viable alternative for people that wish to replace part of a track with a second take (and has the advantage that if pasted in the wrong place it can be undone without undoing the recording of the re-take. Then it can be repositioned and re-pasted).
For people that are looking to replace part of a track with a second take (Punch In), this is probably as close as they will get with Audacity.

I would also like these two effect to be next to each other in the Effect menu, so (as we don’t have any effects management) they need to start with the same letter or few letters. I’m open to other suggestions.

Changed to a generic “Working…”

A bit of background - before this version there were additional options for “Copy”, so I wanted to group together those controls that related to copying, and separately group together those controls that relate to pasting (I would have used “static boxes” had they been available).
Now that the other “Copy” options have been removed, I agree that this can be changed. (more below).

“Looping” and “Single Shot” are common terms in “sampling” and “loop based” editing and these settings provide functionality that is quite closely related to that approach, though I agree that they may not be the most user friendly terms for other users. I think that perhaps sometimes we may try a bit too hard to avoid “technical” terms, for example the “Repeat” effect is a nice layman’s term, but users that are looking for “looping” often have trouble discovering it.

As someone has already pointed out, the “Looping” option can also be used to make new types of waveform in addition to Audacity’s current “Tone Generators”, and in some ways it is better for “looping” than the “Repeat” effect.

Yes, I’ve done that myself :imp:

Excellent idea, I like that :slight_smile:

However it does have one major drawback: It would then not be possible to set the “loop/paste once” option for “Punch Paste” without first using one of the paste option in “Punch Copy”.
I’ll need to think if there is some way round that. (There would be many solutions for a built-in effect, but again we’re running up against the constraints of the very basic interface options available for Nyquist plug-ins).

That would also make it rather odd to call the plug-in “Paste Fill” or similar, as it draws attention to the fact that “Paste Once” does not “Fill” the selection.

That is one of Robert’s feature requests. Unfortunately Audacity does not have access to the Audacity clipboard.

Thanks for the feedback Gale. I’ll have a play around with the interface and naming to see what I can come up with.

Perhaps it just means like the current paste effect when there is a selection ?

For now I have renamed “Puch Copy” as “Punch Copy/Paste” as this plug-in does both copy and paste.
I’m inclined to keep the “Punch” part of the name, because although it does not “Punch Record” I think that for anyone looking for “in-line editing” it makes the effect more discoverable. (Also there is no mention of “record” in the name or interface and it is an “Effect” so there really shouldn’t be any confusion between this and a recording function.

I’ve introduced a small preventative measure against this (easy to make) user error. There are now two “Copy” options:

  • Copy (safe): This is the default. This will only copy if the clipboard is empty. Attempting to copy with this setting when there is already audio on the clipboard will bring up an error message:
'Copy (safe)' protects the clipboard from being 
overwritten. Select action 'Clear Clipboard' to clear the 
clipboard, or use 'Copy (replace)' to overwrite the 
clipboard with the current selection.
  • Copy (replace): This allows the current clipboard content to be overwritten by the current selection (like the original “Copy” option). Although this leaves the potential for users to accidentally overwrite the clipboard content, I think that having only the “safe” option is an unnecessary burden and constriction to work-flow to impose on users that know what they are doing. If users choose to use this option and then accidentally overwrite the clipboard they really only have one person to blame. I would expect that most users that use this effect regularly will prefer this option.

I’m not sure what the “Before” option is supposed to do - isn’t that just the same as “Click and Paste” (insert)?

I’ve added a “Mix” option. Hopefully it is self explanatory, or at least “easily discoverable”.

NOTE: This version is not compatible with previous versions. Please remove previous versions before installing these plug-ins.

It could be useful for pasting before fixed points like labels or split lines.

I hope that will not prove to be the case.

“Fill Copy” and “Fill Paste” are reasonable I think, even if “Paste once only” does not fill. The menu item that does not fill could be called “Paste once (no fill)”.

Perhaps we could think of something that suggests the track length never changes, though I think that might convey less of the purpose than “punch” or “fill”.

I thought when we discussed that, everyone including you decided “Repeat” was preferable (it describes what it does, not what it could be used for)?

I still don’t like “loop” or “looping” here. Without knowing that the selection length does not change, I would guess loop implied that a repeat would be made (irrespective if the clipboard was shorter than the selection) so that the selection was always extended to the end of the track.

How about

“Repeat paste to fill selection?:” (“Yes”, “No, paste once”).

Or if you want a noun:

“Pasting option for long selections:” (“Repeat to fill”, “Once only”).

Well, unless “Punch Copy” only set the paste option and you had to use “Punch Paste” to paste. But I don’t think that would help either.

Although copy (safe) seemed an excellent idea, I’m still overwriting my clipboard because I copy replace, open “Punch Copy/Paste” again to readjust settings for my paste, then forget the action is on Copy replace. This is a large risk if I have been using “Punch Paste” for a while.

Sometimes I will even forget to set intended paste settings while copying because I am focused on the “Copy” action, so go back in to make the paste settings. Being focused on those settings, I forget the action is copy replace. :imp:

Do I take it no mandatory OK/Cancel warning is possible after OK’ing on Copy (replace)?

Can initialisations of “Punch Copy/Paste” after the first in the session be forced to Copy (safe) even if OK’d last time on Copy (replace)?

Is any “backup clipboard” possible which allows recovery from one mistake? Admittedly this could pose a RAM usage problem.

By the way I think “Copy (overwrite)” clearer than “replace” but the wording is not the issue, it is the nature of both copying and setting paste settings.

On the “Mix”, I feel the “0 %” choice and warning is superfluous. I know that a scale of 1- 100 will make unhelpful click increments on the slider, so can “0%” just apply “0.5%” or something?

I did not try the “Eq Power” Crossfade type before, but I don’t understand why if it is selected but the crossfade time is zero (off) that low Paste Mix values reduce the resulting volume even when pasted into audio that is at 0 dB. If it’s a “feature” what is its purpose and why would it not also apply when Eq power crossfades are made (crossfade time is non-zero)?



I think, but I’m not sure, that I know what you mean.
As far as I can tell it seems to be doing what it is designed to do, but it is perhaps not always doing what might be expected.
Could you give a specific example with steps to reproduce.

I think the issue here is that “Equal Power” refers only to the crossdfade, but the “mix” level is a (linear) proportion of the two signals. It is arguable that when Equal Power crossfade is used, then the mix should be non-linear, but I’m not sure if that is what you mean.

OK, I see what you mean.
I think that the closest we could get to that with Nyquist would be “paste once inside and at the end of the selection”.
So that with a selection for A to B, the pasted audio goes just before B:

====|A|-------(paste here)|B|====

Do you think that it would be worth looking at this as a possible addition, or better to avoid the additional complexity?

There’s no-one working on it yet, so that is the situation for now. Of course this could change in the future, but it obviously won’t be an overnight change - a lot of work would need to be done to get it right.

Hmm, possible, but I’m not sold on it yet.

“Paste Special Copy…” and “Paste Special” ?
“Copy/Paste Into…” and “Paste Into” ? (not near each other in the menu :frowning:)
“Paste/Copy Special…” and “Paste Special” ?
“Paste into/Copy…” and “Paste Into” ?
“Mix/Copy/Paste…” and “Mix Paste” ?
“Mix/Copy/Loop Paste…” and “Mix/Loop Paste” ?
“Selection Copy…” and “Selection Paste” ?

Yes, I think we did, but it doesn’t change that some users still don’t find “Repeat” because they are looking for something with “Loop” or “Looping” in the name. Anyway, this is going off topic (my fault :wink:).

Wouldn’t those options imply that the selection will not be filled (i.e. the selection will shrink, putting the rest of the audio out of synch) if “Once Only” is selected and the clipboard is shorter?
By the way, you can’t use a comma in a menu option.

How about
“Selection fill method” choice “Loop paste, Paste into” ?

And that is a user choice.
I could remove the “Copy (replace)” option (or whatever we call it) and force users to use the “safe” option, but I feel that is rather unfair on those users that need to do a lot of:
“copy → paste, copy → paste, copy → paste,…”
because their work-flow then becomes:
“copy → paste, clear → copy → paste, clear → copy → paste,…”
and since the original request was for a method to streamline the work-flow…

Short answers: Yes, No, Perhaps. :wink:

Longer answers:
No mandatory (or optional) OK/Cancel warning is possible after OK’ing for Nyquist plug-ins

Nyquist effects always revert to default settings at the start of the session, then retain the user setting for the remainder of the setting unless change by the user.

It “may” be possible to keep a second copy of the audio on the clipboard (not tested), but as you say, the obvious drawback is RAM usage. RAM usage is currently capped at about 760 MB. I presume that adding a back-up copy would double that to over 1.5 GB which is getting dangerous for many users. There would also be the question of whether “Clear Clipboard” deletes the back-up copy.
If it is technically possible to add a back-up (I think it is), then there could be a “Copy (+ backup)” option which, when selected, reduces the maximum copy size from the current 100 million samples (per channel) to 50 million (just under 19 minutes @ 44.1 kHz).
There would also need to be an “action” option to “Restore Backup”.
I think that it would be necessary for “Clear Clipboard” to delete both the clipboard and the back-up (the back-up is stored on the clipboard).

An alternative, but possibly more useful feature would be to provide (smaller) multiple clipboards that share the same memory space (not tested, but I think this is possible). The user could then decide how many clipboards they want when they first run the effect in a session. The default could be “1 + backup”. With a maximum of (say) 5 clipboards, the maximum size of each clipboard would be about 7m 33s. It would not be possible to change the number of clipboards without first clearing all clipboards. The backup clipboard could (if it works) hold a copy of the last clipboard to be overwritten (so still not foolproof :wink:)

Agreed - I think that was the word I was looking for :slight_smile:

I thought about this. If it really is superfluous, then no-one will ever see it. If that warning message ever pops up, it is because the user has done something badly wrong (probably thinking that “Mix = 0” means “Mix = 100”), in which case the warning(s) should clarify the issue.

Update: Yes it is possible :smiley:

1 Generate a tone at 1.0 amplitude (length does not matter)
2 Tracks > Add New > Audio Track
3 Generate Noise at 1.0 amplitude in the new track
4 Select a few seconds of tone
5 Open “Punch Copy/Paste” and copy
6 Select a slightly shorter section of noise
7 Open “Punch Copy/Paste” and Paste, Eq Power, Crossfade time 0.00, Paste Mix 10%. The resulting selection is at -14 dB, in contrast to the 0 dB of the surrounding audio.

If instead at step 7 I choose “Linear” or “S-Curve” for the Crossfade type, or if I choose Eq Power and turn crossfade on by choosing a non-zero time value, even only 0.01s, then I retain the original peak level (or for EqPower, go a bit above).

I understand (I think) that if I paste quiet audio into loud audio then the resulting audio will be quieter at a high Mix % than at a lower Mix %. This works in EqPower too, but only if Crossfade is on. If Crossfade is off, EqPower has the reverse effect - higher mix %'s result in louder audio.


Thanks Gale, yes that was a bug.
I previously misunderstood and was looking for a bug when crossfade was non-zero, but you meant the bug was when Eq power crossfade = zero. :blush:

This should fix it:
PunchCopy.ny (9.85 KB)
PunchPaste.ny (6.24 KB)

The version in the previous post fixes only the “Eq power: crossfade = 0” bug.

I think there may still be a case for the mix to use “equal power” proportions when “Eq Power crossfade” is selected.

  1. Make 2 tracks.
  2. Generate white noise into track 1
  3. Generate white noise into track 2 (separately so the noise is not the same as track 1).
  4. Use Eq power crossfade and Mix = 50%
    Between the fade regions, the rms level drops below the original level and is noticeably quieter. This is because it is a “linear” mix of the two tracks.
    If “equal power” proportions were used, the peak level would be higher but the rms level (and hence the loudness) would remain constant.

What do you think?
Would you like me to post a version that does this so that you can try it practically?


Your bug fix for EqPower crossfade=off is fine with me.

I would guess “paste inside and at the end of the selection” is a bit obscure, unless you can think of a good use when looping.

I thought about names with “Paste Special” combinations but I don’t think there are enough different features to call it “Special” (that may be a good thing). Also “Special” may give the impression it pastes at the cursor as well.

I quite like “Selection Paste” but it says nothing about what it really does that normal paste doesn’t.

  • “Equal Selection Copy/Paste” and “Equal Selection Paste”?
  • “Sync Copy/Paste” and “Sync Paste”? (But I think that is probably too close to Sync-Locked Track Groups).
  • I don’t think the “Punch” word is bad but I think people may mistake it for what they hope it is.
  • I think putting “Loop” in the name may obscure the use case that initiated it.

I don’t think the second one does so, but I was thinking with those that the plug-in would be called “Fill Copy/Paste”.

I like “Selection fill method” but I think it has the same possible problem as mine (not clear what happens of the clipboard is shorter) unless the effect name makes it clear. The fill is “if required” which I was trying to get at with my second choice above.

But I still don’t like “loop paste” for the reasons I gave. I think choice “Repeat, Paste once” is very much clearer.

But an involuntary one. :cry:

I think we should consider the clipboard backup or multiple clipboards ideas, but perhaps keep removal of “Copy (replace)” as a fallback idea.

It would be an extra control, but would a control for “Copy method:” choice “Copy (safe), Copy (replace)” be an idea? It’s only the one extra first step for the power user to make to set it to “Copy (replace)” on their first use in a session, but the faint hearted could simply leave that control on the default “Copy (safe)”.

I’m not sure if we need five multiple clipboards as well as the backup. There will be no way the user can preview the clipboard without loading and pasting it, will there? In the absence of that it could get hard to recall what clipboard had what content.

The wording will need to be clear e.g. “Split RAM across n clipboards” where n is the number, so they are clear more clipboards means smaller clipboards.

I still can’t see the point of a valid point on the Mix scale being an error.

When we say (to quote yourself)

“Equal Power” means “the power level when cross-fading non-correlated audio remains at unity gain”

I thought the usual interpretation of “power level” was rms level? I would agree it seems more expected to maintain the rms level. Is there a very greatly increased danger of clipping if 0 dB audio is pasted into 0 dB audio than with the linear EqPower crossfade we have now?


The maximum increase in peak level when using an Eq power mix or crossfade is 3 dB.

As it is now (equal power crossfade to linear proportion mix) the peak level is likely to rise to some extent during the crossfade, with a maximum possible increase of 3 dB half way through the fade. Between the two crossfades (the “mix” section, there is no increase to the maximum peak level (easy to see if you test with pasting white noise into dissimilar white noise).

If the mix was with “eq power proportion”, then the peak level could be increased by up to 3 dB in the mix section. Since the peak level is already likely to increase if Eq power crossfade is used I don’t think that the “risk” level of eq power mixing is a problem. Simply, to ensure that there is no increase in peak level, linear or S-Curve crossfades must be used. I’ve tried Eq power mixing and I think it does behave in a more intuitive manner (though the calculations in my current version are slightly off, so I need to fix that).

This saves a lot of time when compared with having to make a section silent and then mix and render tracks otherwise.

As the interface: It seems counter-intuitive that you have to use the “punch copy” to set the “paste” mode.
Also a bit annoying that it doesn’t retain options between sessions.

How can I change the default from “looping” to “one shot”?
I don’t know Nyquist but I have done a little coding, so I can follow simple instructions on modifying code.

Does it use the Windows clipboard?
If so, then I’d prefer if I could just CTRL-C copy and then Punch-paste.
Have “Punch-options” to change options and retain them.

Thanks for the feedback - that was the intention.

Sadly the interface options for Nyquist plug-ins are rather limited, so several of the design decisions were determined by what options are possible.
The reason that the options were all set in the “copy” mode is so that “paste” can be used multiple times with a single shortcut (see the original user case that gave rise to this plug-in: https://forum.audacityteam.org/t/alternate-equal-length-paste-command-resolved/28836/1).
One of the limitations of Nyquist plug-ins is that settings cannot be saved beyond the current session.

Open the PunchCopy.ny file in a plain text editor (for example, NotePad or NotePad++) and on line 18 you will see:

;control loop "Paste: Loop mode" choice "Enable looping,Paste once only" 0

Change the ‘0’ to a ‘1’ so that it says:

;control loop "Paste: Loop mode" choice "Enable looping,Paste once only" 1

Then save the file.
If you use NotePad, ensure that Windows does not change the file extension - the file name must end in “.ny”

No. Nyquist does not have access to the Windows clipboard. It uses a special “global variable” called scratch that retains its “value” (the copied sound) for the duration of the session, or until deleted or replaced.

If you can describe your “user case” in detail, then there may be other modifications possible to make this plug-in more useful.

Does this work in 2.3.0? (I’m using Windows 10.) I dropped the ny files into the plug-in folder in the Audacity program and it does not show up in the effects menu. I’ve rebooted both the program and the computer. The punch files are in the plug-in folder (double checked).

Yes it does.

In recent versions of Audacity, plug-ins have to be enabled in the Plug-in Manager. See: Plugin Manager - Add / Remove Effects, Generators and Analyzers - Audacity Manual

Face palm! That was it. SMH… And thanks.

Under 2.3.1 the versions of the two plugins posted in the 2013 message don’t work right; when you try to punch paste, the cursor location at the time you call up the plugin is lost and all you can do is punch paste to the very beginning of the intended track.

Works for me.
Are you selecting a region to paste into? The plug-in won’t paste at a point, you need to select a region in an audio track.