# Subtract audio to another audio

suppose I have a sample of a snare and that snare is used in a song,¿ there is an algorithm or tool that detects the sound of the snare and subtracts it, that is to say that cancels its phase or eliminates it?.

the result would be the song without the snare sound.

this could also apply to (accordion trumpets or any other instrument)

• what Hilmar said. the problem is that if you hit your snare twice, with exactly the same force, the two sampled recordings will not be the same, even if they sound identical and the envelopes look the same. if you tried subtracting the second snare hit from the first, all you will get is another snare hit. you will not get zero. – robert bristow-johnson Jul 23 '19 at 23:04
• You can try some sparse decomposition techniques (NMF, PLCA), assuming that you have access to snare-only track. – jojek Dec 15 '20 at 10:54

That's a really hard problem. If you have access to the original snare stem and the amount of post processing (effects, panning, mastering) is moderate you may be able to pull some of it out with an adaptive filter.

There are a few commercial plug ins that do this type of thing, but they all have their strengths and weaknesses so it depends a bit on your specific needs

This is a good example of a "simple" problem which is easy to describe to very difficult to solve, and I don't see a direct solution but will put somethings here since this question was bumped.

In the communication systems world, there is a notion of interference cancellation. The idea is that a transmitter is trying to communicate with a receiver but there may also be some interference signal(s). You could model like so:

$$r(t) = s(t) + i(t) + w(t)$$

where $$s(t)$$ is the "signal of interest" (your music without the snare drum), $$i(t)$$ is the interference signal(s) (the snare drum), and $$w(t)$$ is the noise. Interference cancellation is the process of, at the receiver, estimating the interference, re-creating it, and subtracting it from $$r(t)$$ so that hopefully you are left with only $$s(t)+w(t)$$. But, because the cancellation is not perfect, ie. the interference signal is not perfectly re-created, you are actually left with $$s(t)+(i(t)-\hat{i}(t))+w(t)$$, where $$\hat{i}(t)$$ is the estimated interference.

This sort of thing seems to suit your needs, so what is the problem? This interference cancellation technique relies heavily, almost entirely, on being able to very accurately estimate the interference signal parameters. And the estimation relies heavily on being able to write out equations for the interference signal. This is something that would be hard to do for a snare drum (I would think), and would give a weird sounding result.

Another option, perhaps if you observe the snare drum occupies frequencies that the rest of the music does not, you may try filtering. I don't think this would be very promising though.

Something else: place the drummer far enough away from the rest of the band, setup your recording studio with a microphone array and place a nice null in the direction of the drummer!...