# Conditional math (intersection) to join two audio tracks

I do not want the difference. I want the intersection of frequencies.

The problem:

I have two audio files. One of the files (A) contains the vocals and drums. The other file (B) contains the vocals and the saxophone. How can I join the two audio tracks to hear only the vocals? Is there a way to make a conditional union? A union that makes the equal parts appear and the different parts disappear... Maybe?

Thank you!

Unfortunately, there is no analytical way of seperating the signals the way you want, i.e. you can't isolate the vocals.

To go a little more in depth about why there isn't an analytical solution, consider this problem to be one of linear algebra. For simplicity's sake we'll assume our three sources (vocals, drums, saxophone) are in mono, i.e. three vectors of equal length. Now, our sources are mixed in a certain way and we want to "unmix", i.e. seperate them. First, consider the mixture of our sources a result of the operation S * A = M. In this equation, M is an Nx2 matrix that contains the two mixed signals (vocals+drums and vocals+saxophone) as column vectors where N is the number of elements in the vectors (i.e. audio samples in the audio file). S is an Nx3 matrix containing the sources, so vocals, drums and saxophone as column vectors. A is a 3x2 matrix containing the mixing coefficients:

``````    | 1   1 |
A = | 1   0 |
| 0   1 |
``````

In order to seperate three individual channels, we need three mixed signals to work with. Because we only have two, we could try and generate a third signal. For example, we could add the two mixed signals to obtain a third one. M would then be an Nx3 matrix and A an 3x3 matrix:

``````    | 1  1  2 |
A = | 1  0  1 |
| 0  1  1 |
``````

Another possibilty would be to subtract one mixed signal from the other, in which case A would look like this:

``````    | 1  1   0 |
A = | 1  0   1 |
| 0  1  -1 |
``````

So we know M and A, but our goal is to find S—we want to isolate the vocals after all. We can "unmix" M into S if there exists a matrix A⁻¹ so that M * A⁻¹ = S. A⁻¹ is the inverse of A and would allow us to undo the mixing process. An easy check whether a matrix is invertible is to check whether or not the determinant of that matrix is 0. If it is 0, the matrix is not invertible. As you might have guessed, the determinant of A is 0 (for both cases given above) and therefore, A is not invertible. The reason for that is that the third mixed signal we generated is a linear combination of the first two. This will always result in a determinant of 0. That means that there is no matrix containing an "artificially" generated third signal that would allow us to "unmix" the mixed signals into the sources they are comprised of.

If you had a third mixed signal that consisted of drums+saxophone without us having to generate it, then A would look like this:

``````    | 1  1  0 |
A = | 1  0  1 |
| 0  1  1 |
``````

In this case, A would be invertible and we could indeed "unmix" the sources to obtain the isolated vocals.

There are however implementations which seek to achieve source seperation by approximation using models based on prior knowledge of the sources to be seperated.

For reference, the FASST implementation:

Note that the results from the above mentioned source seperation method are most likely not suited to be used for music production purposes. The quality of seperation is not what would typically be needed in music production.

This isn't achievable in musically viable quality. Basically the best pitch is cross-correlating both sources in order to find their offset and frequency content in "lockstep", define this as "signal" and the respective two channels as "signal and noise" and do a Wiener filtering process. However, the result will contain lots of gurgling noises and fade-ins and fade-outs. Naturally, the results will be better if your originals are resulting from different mixes of the same recorded sources rather than taken from different microphones.

But even then, the amount of stuff you can repair is limited. This kind of processing is good for improving comprehensibility of speech signals at the cost of "musical noise", but for musical purposes, "musical noise" is not what you want.