Is there a good method to extract a reference sin/cos from a group of signals?
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:


Two Bin Exact Frequency Formulas for a Pure Real Tone in a DFT
Phase and Amplitude Calculation for a Pure Real Tone in a DFT: Method 1


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?)