I just need some advice on a project. I have an unwanted sinusoid that has time-varying frequency (its not sinusoidally varying) which is relatively constant over a small section. I've been advised to use a Linear Predictor in order to deal with it and remove it.

I just need some advice on how to go about implementing it. I understand the theory, my main issue is with this equation for a forward-linear predictor

$$ \hat{x}(n) = \sum_{i=1}^p a_i\,x(n-i) $$

Now, what's the point in estimating the next value of the signal if it's also going to contain the same unwanted sinusoid component? I understand how to use this (finding coefficients using Yule-Walker/Levinson-Durbin)

EDIT: More info, Sinusoid is added on top. I can almost hear the telephone conversation clearly when the sinusoid dips down. I understand that for a small enough section, I could just use a notch filter but of course it's not feasible to do this for each small section manually. I need a way of predicitng it's frequency hence the linear predictor The sinusoid has a significantly higher amplitude than the conversation and it's frequency varies from 200Hz to 2kHz

  • 2
    $\begingroup$ This is speculation, because we don't know the exact wording or intention with which you were advised, but: The idea of prediction here might simply be to predict the sinusoidal signal component's frequency, to be able to reconstruct the pure sinusoid and subtract it from your signal. But you don't tell us in which context, or as what part in a composite signal your sinusoid "happens", so it's hard to interpret. Can you explain your overall goal (eg. "remove frequency-varying hum from telephone conversation" or "remove varying frequency shift from satellite RF signal")? $\endgroup$ – Marcus Müller Nov 17 '18 at 15:47
  • $\begingroup$ @MarcusMüller It's a telephone conversation with a sinusoid added on top whose frequency varies with time. $\endgroup$ – AlfroJang80 Nov 17 '18 at 16:30
  • 1
    $\begingroup$ what a coincidence that your problem happens to be exactly one of my examples! So, you still don't tell us how your sinusoid is related to the conversation: additive, multiplicative? What did your advisor say you should linearly predict? $\endgroup$ – Marcus Müller Nov 17 '18 at 16:32
  • 1
    $\begingroup$ Please edit your question to include that info. $\endgroup$ – Marcus Müller Nov 17 '18 at 16:36
  • 2
    $\begingroup$ @MarcusMüller done $\endgroup$ – AlfroJang80 Nov 17 '18 at 16:47

So, the algorithm I'd propose is the following:

  1. Filter your input signal with a 200 Hz – 2 kHz bandpass filter
  2. Since in that band your sine is the dominant oscillation, a PLL would lock onto that. So, use a second-order PLL to track that wave; there's many PLL implementations that'll output the reference as tone with the correct phase.
  3. Typically, PLLs lose amplitude information, so you can't simply remove the sinusoid by subtracting it from the audio signal. Instead, you'd use the reference tone to multiply the signal with, which mixes down the original tone to 0 Hz. A low-pass filter (in this case, even a single-pole IIR) might be trivially used to extract the instantaneous amplitude.
  4. Now that you have the right tone with the right frequency and phase, you can subtract it from the input
  5. To predict how the tone is going to be developing its frequency, you could use a linear predictor, but honestly, a second-order PLL is a linear predictor for phase (a linearly changing phase is a sinusoid; the coefficient of the linear term is the frequency). If you need to work with a sinusoid which might be undergoing a linear change in frequency: third order PLL.

Even more elegant: Use the output of 2. Mix your signal down with this. Apply 0 Hz Notch filter (again, single-pole IIR might do, or other kind of narrow high-pass filter). Shift up in frequency again.

  • $\begingroup$ Great answer. Thank you very much. Is there any way to do it without a PLL? $\endgroup$ – AlfroJang80 Nov 17 '18 at 17:12
  • $\begingroup$ sure. But it's not the way I'd do it. That'd require more elaborate frequency estimation, and then your linear prediction step would usually be even more be in need of mathematical rigor to make sure you don't hurt yourself. $\endgroup$ – Marcus Müller Nov 17 '18 at 17:15
  • $\begingroup$ Ah I see. We haven't done much PLLs in class. Obviously, it looks like the superior method. One last question - for a linear predictor for this problem, I'm just having some trouble figuring out what to do after I've gotten my predicted value for my signal for a certain frequency constant segment. Like doesn't that mean I've just predicted the same bad signal? I think it's something to do with the residual error and how that correlates to the unwanted sinusoid in the original signal $\endgroup$ – AlfroJang80 Nov 17 '18 at 17:44
  • $\begingroup$ really, your linear predictor for the phase / frequency of a sinusoidal is a PLL. $\endgroup$ – Marcus Müller Nov 17 '18 at 18:08
  • $\begingroup$ Hmm. I see. My instructor insists on using a standard linear predictor. I saw an example where the MATLAB function lpf() worked quite well. I tried it out on my signal to get the filter coeeficients and then filtered it and it did work quite well. I'm trying to implement that by myself now (without lpf function), and I'm just having trouble with that. I have segments of about 200 samples and I'm planning on solving the Yule-Walker equations on each segment of 200 samples, getting coeffs, filtering each segment and then stitching it back togehter. Would that be a good idea? $\endgroup$ – AlfroJang80 Nov 18 '18 at 1:43

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.