Remove lagged second recording of same audio

I have an audio file (one track I’m afraid) which has the same audio recorded twice with a short lag between them. This second source was recorded in error (and is identical to the first) and I’d like to strip it out. Is it possibly to programmatically (or even better automatically) duplicate the initial clean part before the second source starts, invert it, time-shift by the lag, then combine creating a new clean segment, and repeat until the end?

I know this is a long-shot and even if it is possible may be rather tedious… but I live in hope!

Many thanks in advance!

MacOS 10.4
Audacity 2.4.2

Theoretically, yes. Do you know the exact offset (in samples) between the two recordings?

– Bill

Many thanks for your reply, Bill.

Yeah, I was hoping to infer this from the recording, but the difficulty is getting this exactly, which will be necessary to do the cancellation, right?

Do you think without this information it’s a lost cause?

You need to be accurate to the sample to get a perfect cancellation. I tried it. I knew that the second recording was offset exactly 1 minute, so it was easy to go through the steps you proposed. The result was successful. The second recording must also be exactly the same volume as the first recording.

You want to find the offset between the recordings, so finding any easily-identifiable sound that repeats is the goal.

In the first portion of the recording (without the overlap), find a loud percussive event. Zoom in and mark it with a label. Now try to find that event in the first overlap section. Mark it with a label. Select between the labels and note the length of the selection. Set the Selection toolbar to display “Start plus Length of selection” and to show hr:mm:ss + samples. Try using a selection of that length and see if it works. If you hear comb filtering then you’re close - adjust the selection length 1 sample at a time until you get it perfect. If you get almost-perfect cancellation (no comb filtering and no audible delay) you may need to adjust the volume of the inverted track.

Good luck.

– Bill

Doesn’t that require that you have a “clean” recording to subtract from the mix?

Sorry, I meant 1 minute. I’ll go back and edit my post,

The OP seems to have a recording that has a second, identical recording mixed into it starting some time after the start. As he pointed out (and I tried to replicate), you can clean up the recording in segments. Say you have 1 minute of clear recording at the start. Select that 1 minute, duplicate it to a new track, invert it and time shift it 1 minute. Mix and render. Now you have 2 minutes of clean recording. Select the newly-clean 1-minute portion starting at the 1 minute mark and repeat.

So I tried this by importing a song, duplicating it, time shifting the copy by exactly 1 minute then mixing the two tracks. With the above method I was able to recover the original recording.

– Bill