# Filter away sinusoidal noise properly

I have a stereo music signal corrupted by strong sinusoidal noise that varies over time. Here is the spectrogram of Left channel I plotted with Matlab. As you can see there are 3 or 4 strong harmonics with frequency that varies over time.

As a first try I computed the difference of left and right channels and it seems most of the harmonic noise disappears, so my guess is the noise in left and right are almost identical. Here is the difference spectrogram to prove this.

Which technique could I use now to filter away all the interfering harmonics while preserving the original music spectrum as well as possible?

• Notch filters?
• Tracking the frequencies over time and adding a sinusoid with reversed phase?

How do I estimate and use the phase information? I think phase is important to have good denoising, but would not know how to proceed.

Thanks a lot! :)

• Why is your spectrogram vertical?
– A_A
Dec 28 '17 at 9:58
• Matlab plots it like that by default. I think it is quite ok, easily readable. Dec 28 '17 at 12:00

Definitely, try to reconstruct the sine and then subtract it. A notch filter will create artifacts as the desired signal changes, with notes stopping and starting, and percussion. Even if those notes are at pitches of frequencies outside the range of the notch filter.

To extract the unwanted sine, use a bandpass filter. While this has the same problem as the notch filter, with notes stopping and starting, you do know that the sine is steady (or slowly varying) over time, while the desired signal is always changing. Or may include some steadily droning elements - bagpipes, anyone? Hope that's outside the passband of the filter. You also have found how the sine and the signal related between left and right, so make use of that to help extract the sine. The electronics engineer part of my brain wants to send the extracted sine to a PLL, to filter out any accidentally included signal, and provide smooth amplitude and phase data. Some sort of mathematical flywheel to steady the cycles.

The exact methods for extracting and purifying the sine depend on if you need to do this in real time, or near real time with a fraction of a second delay acceptable, or if you have the whole span of signal from beginning to end all at once such as with an .mp3 file.

I know this is the best way to do it, because Cassini's NAC camera had a similar problem. You have the audio version of what I had to fix years ago.

• Thanks, that Cassini NAC camera story is quite cool! Could you please explain better your line of thought? I understand the idea of bandpassing around the unwanted harmonics to isolate them and then using some sort of correlation between right and left to get clearer estimation and then what shall I do? Shall I just add a cos function with same frequency and opposite sine in the time domain? Also, how do I generate this denosiing additive signal? PS: I don't care much about real-time efficiency. I have access to the whole music piece and would like to make it sound as good as possible! Jan 4 '18 at 11:14

Just an idea. If rest of the signal in both left and right channel is stochastic, you can take each channel at a time and look for autocorrelation. I suppose you should see peaks corresponding to time delay consistent with period of these sinusoids. Using left and right channel independently will help you to discard false alarms. Once you know the peaks use a notch filter with variable cut off frequency to ellininate the harmonics.

• I see, thanks! But the signals below are not stochastic, it is a music pieace by Bach and the left and right channel are almost identical because it is a stereo audio recording of an harpiscord or a similar instrument. So I don't know if this is a good idea.. Jan 4 '18 at 11:11