Remove gaps between audio clips, push clips together

This is a common situation. The user isolated clips that are interesting and wants to push them together so they can work with them on a compact space and decide whether to export them individually or together in one and maybe perform fades.

From this:

To this:

Manually achieving this involves very unsatisfactory dragging with insecurity whether they are a snug fit or use of a lot of cut paste and jumping to the end.

In Premiere, you have the benefit of being able to select (leftclick) empty space between clips and delete them, knowing for sure the clips are next to each other. In Shotcut, you can right-click empty space and “ripple delete”. In Audition, you can right-click empty space and Ripple Delete > Gap as well as Edit > Ripple Delete > Gap in Selected Track, which is active if the playhead is currently on top of empty space.

Using Truncate Silence is an incredibly weird workaround with unusable defaults and requires understanding of a completely unrelated workflow. A different conversation drifted into nothingness.

I’d like to suggest Audacity adds the ability to

  1. Edit > Audio Clips > Remove Gaps to remove gaps in the entire project or if a selection exists, between all clips touched by the selection
  2. The ability to right-click empty space and delete it

Align Tracks already provides similar functionality for tracks. Let’s bless Clips with advanced basics too! :smiley:

2 Likes

I agree with @NomNomSounds and was quite surprised there was no way to bring the clips together without dragging each one individually.

Because of what I want to do next, I do not want the clips to become merged into one as occurs when you use Truncate Silence as advised in another post.

Is there perhaps a way to bring all the clips together with a Nyquist script?

Thanks,
-Tony

You can do it with a macro, but it’s clunky since macros have no control structures (looping, counting. if-then, etc).

The attached macro works. Because of a bug in the macro implementation you have to start with the last clip.

Click inside the last clip in the track and invoke the macro repeatedly until all clips are pushed together.

I’d not be surprised if Steve comes up with an elegant solution in Nyquist.

See here for information about macros.

PushClipsTogether.txt (59 Bytes)

@billw58 thanks for the reply.
update: right after making the post below, I found out macros are stored at ~/Library/Application Support/audacity/Macros
so dragged your .txt into there, restarted Audacity and it worked. Then I made a shortcut to executing it and voila! So now I have a work-around – thanks!

One problem with this is that one has to know how many times to apply the macro. Of course, this is obvious if you are doing it manually, but I was trying to make a Keyboard Maestro script to control Audacity in a much larger workflow. I keep getting stuck when I try to control Audacity that way too.

I’ll keep my post below to perhaps help other newbee’s realize they’re not alone…
…
I tried to make the macro, but it didn’t go so well.

First, I looked for somewhere to paste your code text – didn’t find, so I started using the Select Command dialog.

But then I got stuck because I couldn’t find the 2nd command “SelPrevClipBoundaryToCursor:” – see my 1st screenshot. I’m aware that you can set parameters with some in that list, but as you can see there’s no option for that with the one I selected – and nothing nearby looked promising.

So the next thing I did was push the help button at the lower right and this is the page I got:

Glad you got it working.

I guess I should have provided a bit more detail. In the Manage Macros dialog there is an Import button. That does the work of moving the macro file to the correct location.

I have never been able to get Keyboard Maestro to work with Audacity.

I’m sorry to hear this, but it matches my experience. I can see that a lot of effort has gone into making Audacity “scriptable” (macros, nyquist prompt, ability to make larger Nyquist scripts). All that work is so users will be helped – and it’s really wonderful when you can control an app like that. But I wonder how many actually have the skill to use those features in Audacity?

Keyboard Maestro is also quite a challenge, especially when the apps being scripted cannot easily be controlled with keystrokes instead of a mouse. And that’s the case here, it seems – at least I don’t know how to use Keyboard Maestro to count the number of clips and then drag them together.

First time offering thoughts. I have worked a bit with OpenShot Video Editer. It has a feature called Remove All Gaps. I was a bit surpised to learn that Audacity did not have this feature despite having so many editing tools. I have used several of those tools and work great. However, if I am editing an audio file where I have just spliced the file 100 times and have made numerous cuts for the purpose of creating 100 individual sound files, I am left with a lot of gaps. Manually closing those gaps has been the most time-consuming task to perform. Using macros seems like a plausible work-around, however, with my luck, I would create a small bomb on my project the moment I run it. I look forward to the toolbar EDIT suggestion made above. CHEERS to all who have made Audacity what it is today!!!

I know this is an old post, but I just now saw it.

Here is how I would remove gaps in the tracks. I would generate silence between each of them as I went, then use the Truncate Silence effect to remove them.

I agree and also request this. Honestly, it blows my mind that this function isn’t available. EVERYONE else provides this. I use it hundreds of times in each project. It is a huge pain in the neck to manually adjust. And I can see that you can fiddle around with macros and then guess at its application but honestly, this is such a basic and important feature. It’s 2025, guys, not 1998. Come on.