For the removal of a pure interference from a group of sampled signals, if I know the exact frequency of the interference I can simply use an I/Q demodulation technique (i.e., a phasor projection) to calculate it and remove it from the signals of interest. But I don’t have a pure version of the interference so I need to derive it from the data.

I know this is related to clock recovery, but with limited signal record lengths any control loop (e.g., PLL or DLL) would be problematic.

So far I have simply hacked together an ad-hoc relatively long sequence of bandpass filtering, limiting, bandpass filtering, normalization for the I reference and afterwards all-pass filtering/Hilbert transform and normalization for the Q reference. It seems to work, but it’s too much of a hack. And it gets complicated if there are multiple interferers.

Is there a better/simpler way to extract these references?

If not, what would be a good alternative for simple bandpass filters? (as the requirements for these are quite stringent.)

If this was implemented in a real-time system (continuous data stream) instead, would you go the PLL/DLL route, or would this technique be good enough or even equivalent?

Although the most common method to remove these types of interference is to use a notch filter, the ringing in the impulse response of such filters is unacceptable for many applications.

This is particularly true for applications in which an intentional impulsive large artifact is present.

  • 1
    $\begingroup$ If you know the exact frequency, the simplest solution would be a Notch filter tuned exactly there. Maybe you can explain what prevents you from using such a simple technique. $\endgroup$
    – Florian
    Jun 28, 2019 at 7:27
  • $\begingroup$ I added a comment of why notch filters don’t work here. Their impulse response is unacceptable. $\endgroup$ Jun 29, 2019 at 11:09
  • $\begingroup$ By "pure interference" do you mean an interfering pure tone? If so, does it make a distinct peak in the DFT? $\endgroup$ Jun 29, 2019 at 11:22
  • $\begingroup$ @CedronDawg yes. A pure tone (and perhaps a few harmonics that can be treated the same way). $\endgroup$ Jun 29, 2019 at 13:06
  • 1
    $\begingroup$ I've posted working Gambas code at forum.gambas.one/viewtopic.php?f=4&t=728. It is a tar.gz file, if that is troublesome I can also post it as a zip. Gambas is a dialect of BASIC so the code should be quite understandable. If you have Linux you can install Gambas easily, it is open source. The code is for the tone parameter estimation, it does not address the frame by frame processing. $\endgroup$ Jul 5, 2019 at 18:57

1 Answer 1


The best way to accomplish your desired result is to estimate the parameters of the interfering tone(s) and remove it(them) from the signal in the time domain.

To get you started on how to go about this, I recommend you read these two articles of mine:

This needs to be done frame by frame, so there are a whole bunch of implementation details that come into play. I'm really busy right now, so I will come back later with a fuller explanation.

For the two bin frequency formula, for best results, you will want to define your frame length on an integer + one half number of cycles. That way you only need to calculate two DFT bins. The amplitude/phase method will work on just two bins, but you will probably want to do four for that.

Given what you have said, this approach should be very plausible.

I would state that fact as you have 250 samples per cycle. So suppose you aimed for 2 1/2 cycles, that would mean a frame length of 625 samples. Any size in that range will put the interfering bin solidly between bin 2 and 3 (zero based indexing) and those are the only DFT bins you need so calculated a full DFT via FFT just for two bins is inefficient. The longer duration you have, the more bin separation you get between frequencies, but less well the DFT works unless the tones are steady. All the DFT cares about is sample counts, not what the underlying time scale is.

The proper units for frequency is cycles per frame which corresponds to the bin index or cycles per sample which you have given as 1/250.

Sample code is coming, and so is a further explanation. You need to think in terms of frames, constructing a copy of your interfering tone in a separate set of buffer because you will need to have overlapped buffers. Further details also forthcoming.

Still working on my two bin coding. Hope you are too.

You want to think of your signal as a series of frames. For each frame you are going to take a reading of the interfering tone. Some frames will be good reads and some frames will be bad reads, and it is important to have a metric which tells you the quality of each read so you can set a threshold.

You will read the frequency and the amplitude and phase are best done as a cartesian complex number. You will want to interpolate these values over a span of the good frames to give you parameters to generate a copy of the interfering signal so you can subtract it from your signal.

The reconstruction can be done by overlapping frames with averaging in the time domain as I said before, or a better way is to do a higher degree approximation of the angle in the sinusoidal function.

This method should work quite well for a slowly varying pure tone. (and possibly the basis of a music compression algorithm?)

  • $\begingroup$ It’s not really possible to set the number of bins to an exact multiple of the interferer frequency as the sampling rate can’t be changed and is not related to it (and it seems a bit overkill to oversample/sub sample just to achieve this result) and the frequency would have to be determined to a higher precision than what seems necessary. $\endgroup$ Jun 29, 2019 at 14:40
  • 1
    $\begingroup$ No, it doesn't need to be exact. Having the frame just be near a whole number plus a half is sufficient. This puts the "peak" close to the center of two bins. For a noiseless pure tone the frequency calculation will be exact. I also have a change to the amp/phase calculation that makes it more noise resistant, but likewise it too is exact on a pure tone. $\endgroup$ Jun 29, 2019 at 14:49
  • $\begingroup$ If the frequency is near a whole number of cycles per frame you would want to use my 3 bin formula instead, centered on the peak bin. It is also exact, regardless of N, for a pure noiseless tone. You might have been told that is impossible, but I am telling you it is not. dsprelated.com/showarticle/773.php $\endgroup$ Jun 29, 2019 at 14:52
  • 1
    $\begingroup$ @EdgarBrown, Sorry, I haven't gotten back to this yet. I am writing some code to demonstrate the principles, but no time today, maybe not tomorrow. If you are pursuing this yourself, the improvement on the amp/phase method I spoke of is to unfurl the two bin DFT complex values into a single four element real valued vector. This forces "a" and "b" to be real and takes away the complex portion absorbing the error. $\endgroup$ Jun 30, 2019 at 17:47
  • 1
    $\begingroup$ @EdgarBrown Right. I've added a little to my answer. $\endgroup$ Jul 1, 2019 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.