Before machine-learning source separation, the classic way to remove vocals from a song was a single line of maths: subtract the right channel from the left. It still shows up in audio editors as a 'vocal reduction' or 'centre cancel' effect. It works just often enough to be tempting and fails often enough to be frustrating. Working through it in NumPy makes it obvious why.
Mid and side
Any stereo signal can be rewritten as two other signals:
Mid = (L + R) / 2, everything the two channels share.
Side = (L - R) / 2, everything that differs between them.
In many pop mixes the lead vocal is panned dead centre, so it is identical in both channels. It lives entirely in the mid signal and contributes nothing to the side signal. Keep only the side and the vocal disappears.
import numpy as np import soundfile as sf
audio , sr = sf . read ( 'song.wav' ) # shape (n, 2) left , right = audio [ : , 0 ] , audio [ : , 1 ]
side = ( left - right ) / 2 sf . write ( 'side_only.wav' , np .…