Thoughts on plugin to remove smart clip hidden audio

I’d like to write a plugin to work around the file size issue here: Smart clips file size issue (file size doubles after copy + effect).

Initial idea for process to be automated:

  1. Insert a short silence before and after a selected clip
  2. Join the clip to the silences
  3. Delete the silences.

This would add a tiny amount of hidden silence, but since I’m thinking on the order of 1 ms (maybe going up a little higher if anything seems buggy when using an interval that small), and it would be hidden anyway, that’s close enough to zero for me.

Question 1: Can this be done purely with a macro, or does the fact that we need to do stuff based on the start and end of the selection make that impossible?

I was thinking a nyquist tool might work, but now I’ve run into the issue that none of the built-in generators allow specifying a duration when it’s used in a macro. The nyquist ones do, but as I understand it it’s not a good idea to call nyquist from nyquist.

Question 2: is there any command or effect that will let a nyquist tool insert sound at the cursor?

I thought I’d be really clever and copy a piece of the clip and silence it, and then use that as my silence, and I even got it working! Except whoops, it turns out that copy is a smart clip, too, so my 5 ms of silence still has the entire original clip attached…

I imagine it’s possible to write a nyquist generator that just returns the selected audio (actually, do generators have access to selection information?), but frankly I’m not sure I’d trust that to fix the issue, since audacity is perfectly happy to let you replace a subclip with generated silence without modifying the hidden sound to the left or right of the clip at all.

I know mix-and-render has been suggested as a way to get rid of extra clip information, so some sequence of duplicate, then mix and render, then replace the original selection with the duplicated version, might work, but if the original track had any real-time effects enabled, those will now be baked in.

Question 3 Can nyquist turn off real-time effects for a track?

I know nyquist can get you clip information, but I haven’t messed around with it much, and I imagine it hasn’t been updated with smart clip information yet, though that does seem like an interesting avenue for a plugin that would clean a project and remove audio from all clips, rather than relying on a single clip being fully selected.

Anyway, does anyone else have thoughts on this? If someone already has a plugin that gets them most or part of the way there, that would also be interesting to know about.

Why not just delete the parts that you don’t want? (“Del” key or “Ctrl + X”)

Why not just delete the parts that you don’t want? (“Del” key or “Ctrl + X”)

This is specifically for the case where:

  1. I have a long clip of audio
  2. I copy a short sub-clip of it elsewhere within the same project
  3. I now want to remove the hidden audio from the new subclip

This prevents doubling the size of the project if I later apply an effect to the original longer clip, or would allow me to copy the subclip into a new project without accidentally dragging along the entire audio information of the original longer clip

I’m unaware of a way to use delete to remove the hidden audio from the subclip, and as far as I’m aware (although I’m not at my computer right now to check) creating a subclip by deleting audio from either end of it creates a smart clip with hidden audio, rather than permanently deleting that audio.

My goal is a solution that works whether or not the track the subclip is in has real time effects on it, and whether or not the subclip is on its own track

I figured the generation out–I can use the following function to generate silence beyond the end of the project:

(defun generate-silence-to-clipboard(duration)
  ;; create some silence after the very end of the project
  (aud-do-command "SelectTime" :start (- 0 duration) :end (- 0 (* 2 duration)) :relativeto "ProjectEnd")
  (aud-do-command "Silence")
  (aud-do-command "Cut"))

The rest of the plugin is mostly done, but I keep getting a lot of “off by a sliver” errors that seem like they could potentially be caused by rounding errors when I’m selecting the audio at various points. A couple times it’s left a tiny clip behind, once it didn’t actually trim the hidden audio, just inserted some silence into it (I’m guessing the silence I inserted wasn’t quite at the start of the original selection, and that the join joined around the silence instead of into it. I’m still working on pinning this whole bit down.

How about something like this? It creates a clip from the selected audio into a new track. You can then drag or Cut / Paste the clip wherever you want it.
Note: The selected audio must be in one track only.

Safe_Duplicate.txt (44 Bytes)
The code: