mathmax wrote:Is it possible to compare the waves point by point and for each couple of point take the one with lowest amplitude to create a new wave.
Yes that can be scripted in Audacity using
Nyquist but I don't think it will produce the result that you are expecting.
Both the backing and the vocal are waveforms that are oscillating independently with positive and negative values. At any given point, the value of a sample is the sum of the backing component and the vocal component, but as either of these may be positive or negative, the sum may also be positive or negative. There is no direct correlation between the minimum sample value and whether the sound comes from the vocal or the backing. Although there will be some degree of reduction in the background (assuming identical voice), the result will also contain distortion/noise.
The most simple way would be to do bit-wise comparisons (read one sample of each and compare them, then read the next sample from each), but that would be extremely slow. A much faster method is to use the (s-min) function as this can do bit-wise comparisons of entire sounds rather than having to script a loop through individual samples.
If you want to try it, import both tracks into Audacity and make them into one stereo track by clicking on the name of the upper track and select "Make Stereo Track".
Select the stereo track and from the Effect menu select "Nyquist Prompt".
Copy and paste the following code into the Nyquist Prompt box and click OK.
Code: Select all
(let*
((PosL (s-max (aref s 0) 0))
(PosR (s-max (aref s 1) 0))
(NegL (s-min (aref s 0) 0))
(NegR (s-min (aref s 1) 0))
; compare positive parts
(MinP (s-min posL posR))
; compare negative parts
(MinN (s-max NegL NegR))
; compare PosL with NegR
(MinPN (s-min PosL (mult -1 NegR)))
; compare NegL with PosR
(MinNP (s-min (mult -1 NegL) PosR))
; correct sign for MinPN and MinNP
(MinPN(mult -1 (clip(mult ny:all(sum PosL NegR))1)MinPN))
(MinNP(mult -1 (clip(mult ny:all(sum NegL PosR))1)MinNP)))
(sim MinP MinN MinPN MinNP))
A brief summary of how the code works:
(s-min) is a function that computes the minimum of two sounds.
(s-max) is a function that computes the maximum of two sounds.
As the amplitude may be positive or negative we need to calculate the minimum amplitude of the positive and negative parts of the wave, then stick the parts back together.
A couple of other points:
It is a bit risky using special characters in file names (such as back-slash and apostrophe) as such characters are not valid on many machines and incompatible with some programs. It is generally safest to stick with alpha-numeric characters, space, hyphen and underscore.
Although the voice on the two samples sounds are from the same original recording, they are not identical. The voice is about 4 dB louder in "
1'55_left (with amplification t 0 b 0.6)" than in "
1'35_left (with amplification t -0.6 b 0)" and about 5 milliseconds (250 samples) earlier. To avoid just producing bad distortion you will need to carefully align the two tracks.
The result of this "lowest common sample" script applied after adjusting the time position is attached: