I know this is a rather common and a rather simple problem, but somehow I can't find a solution that is equally simple to understand (and implement).

I have a signal that closely resembles a noisy sine wave (sample signal graph below). What I actually need for the practical problem I'm solving is to find the phase of that signal, more specifically - one of the extremum points for each period. I want to know at which sample the new period starts, either from the min or from the max point (doesn't matter which as long as I know which one it is). A real-time solution is preferable (i. e. with as little a delay as possible).

enter image description here

What are good general approaches to this problem? Do I need to find the fundamental frequency? If I do, I have found two algorithms for that: DFT/FFT (overkill because I only need the base frequency), and auto-correlation which would be my choice. Is there any simpler way than auto-correlation?

Of course, if there is a more direct way to get the "starting" point of each period, that would be even better.

Thanks in advance.

P. S. The naive solution I see as an engineer with no training in DSP is to apply a smoothing (low-pass) filter to the signal and calculate something resembling a derivative - s(t) - s(t-1). Where this value changes sign is an extremum - but only with sufficient filtering and sufficiently stable signal. This approach does not seem robust.

  • 1
    $\begingroup$ I would have suggested detecting the frequency and then using a correlator. But that's already on your list. As a low-complexity heuristic, why not detect the zero crossings instead of the peaks? This would look easier to me. Of course, if the signal is noisy, this will fail at some point too. You already have a collection of methods from complex to simple, I suggest you try them on your signals to see if they satisfy your needs. Hard to suggest anything more concrete without knowing what exactly you want to do with the phase and how badly your signals are distorted. $\endgroup$
    – Florian
    Commented Sep 5, 2019 at 16:30

1 Answer 1


You could try to Fourier transform,

$F(k) = \int_{-\infty}^{\infty} x(t) e^{-2\pi i kt} dt$

which can be expressed in terms of magnitude and phase in the following way

$F(k) = |F(k)|e^{i\Phi(k)} = a(k) + ib(k)$

with magnitude $|F(k)|$ and phase $\Phi(k) = \tan^{-1}(\frac{b}{a})$ for each frequency component $k$. Since it looks like you have a dominant $k$ representing your sine wave you can find the phase of that wave pretty easily. There are probably more obvious ways than this though.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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