Hi, I need to calculate the delay between two signals which are not periodic signals but they are similar except the second signal having different amount of delay at different points. Would anybody please suggest which algorithm will be better to find this different delay at different position of second signal corresponding to first signal ?? please help..
Delay calculation between two signals
Started by ●September 5, 2013
Reply by ●September 5, 20132013-09-05
On Thu, 05 Sep 2013 09:03:39 -0700, mriheen wrote:> Hi, > I need to calculate the delay between two signals which are not periodic > signals but they are similar except the second signal having different > amount of delay at different points. Would anybody please suggest which > algorithm will be better to find this different delay at different > position of second signal corresponding to first signal ?? > > please help..There's not nearly enough information there to say. You're probably going to have to roll your own, unless the "reference" signal looks just like something used in radar or some such. The approach that will probably work will be to look for features in the reference signal that you can detect in the second signal, then determine their timing. But without detailed knowledge of the signals in question -- I just can't say. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by ●September 5, 20132013-09-05
On Thursday, September 5, 2013 9:03:39 AM UTC-7, mri...@gmail.com wrote:> Hi, > > I need to calculate the delay between two signals which are not periodic signals but they are similar except the second signal having different amount of delay at different points. Would anybody please suggest which algorithm will be better to find this different delay at different position of second signal corresponding to first signal ?? > > > > please help..Not enough information to get a good answer. For a discussion of some techniques: ftp://ftp.apl.washington.edu/incoming/williams/InSAS/Time%20Delay%20Estimation/giovani_discrete-time-tde.pdf Dale B. Dalrymple
Reply by ●September 5, 20132013-09-05
mriheen@gmail.com wrote:> Hi, I need to calculate the delay between two signals which are not > periodic signals but they are similar except the second signal having > different amount of delay at different points. Would anybody please > suggest which algorithm will be better to find this different delay > at different position of second signal corresponding to first signal > ?? > > please help.. >Start with deconovolution. But be careful. For example, I have successfully used deconvolution to calculate the "delay" between a mic signal and a peizo pickup signal on an acoustic guitar, but the are times it doesn't work. -- Les Cargill
Reply by ●September 5, 20132013-09-05
On 9/5/13 9:03 AM, mriheen@gmail.com wrote:> > I need to calculate the delay between two signals which are not periodic signals but they are similar except the second signal having different amount of delay at different points. Would anybody please suggest which algorithm will be better to find this different delay at different position of second signal corresponding to first signal ?? >dunno if it's the "best", but windowing segments of the 2nd signal (i'm inferring that there is a slowly varying delay of the 2nd signal with respect to the first) and cross-correlating those windowed segments of the 2nd signal against the 1st should give you an idea. look for which delay lags result in the maximum amplitude of the cross-correlation. a large *negative* amplitude means a high correlation with a polarity reversal in one of the signals; for a sinusoid (which i don't believe is the case here) this is indistinguishable from a positive correlation and a different delay of 1/2 period. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●September 5, 20132013-09-05
I would suggest; 1) compute the analytic signal for each of your inputs in the time domain, using either FIR or IIR parallel filters. 2) compute the magnitude of each of the complex signals computed above. 3) search for the maximum cross- correlation for the magnitude signals computed above. 4) if you need better than 1-sample accuracy then find the true peak using quadratic interpolation around the peak (posted here on comp.dsp many times). I have to admit that I'm guessing that using the analytic envelope would give a better result than using the signal itself. I have more neurons in my gut than in my brain. Bob
Reply by ●September 5, 20132013-09-05
Of course if you have the dsp power to do frequency-domain processing then that's the best choice, just take the fft of both signals, convert to polar, subtract phases and divide by bin frequency to get a delay estimate per bin, then average all those delays together. If the signal is very long then break into windowed segments. Bob
Reply by ●September 5, 20132013-09-05
Hi, I've got a piece of code that may do the job in Matlab, here: http://www.dsprelated.com/showarticle/26.php You already mentioned they are NOT periodic, so you'd need some kind of windowing. If the windowed regions aren't the same for signals A and B, the result is biased, as the algorithm is "pulled" towards maximizing the area of overlap. Note, there are two completely independent algorithms in the code snippet. The second one (iteratively time-delay and maximize crosscorrelation) is probably easiest to modify, also doable in real time. _____________________________ Posted through www.DSPRelated.com
Reply by ●September 6, 20132013-09-06
On 9/5/13 10:48 AM, radams2000@gmail.com wrote:> I would suggest; > > 1) compute the analytic signal for each of your inputs in the time domain, using either FIR or IIR parallel filters. > > 2) compute the magnitude of each of the complex signals computed above. > > 3) search for the maximum cross- correlation for the magnitude signals computed above. > > 4) if you need better than 1-sample accuracy then find the true peak using quadratic interpolation around the peak (posted here on comp.dsp many times). > > I have to admit that I'm guessing that using the analytic envelope would give a better result than using the signal itself. I have more neurons in my gut than in my brain. >On 9/5/13 11:35 AM, radams2000@gmail.com wrote:> Of course if you have the dsp power to do frequency-domain processing then that's the best choice, just take the fft of both signals, convert to polar, subtract phases and divide by bin frequency to get a delay estimate per bin, then average all those delays together. If the signal is very long then break into windowed segments. >i don't see the use for doing this in the frequency domain at all. the OP says that the "second signal [has] different amount of delay at different points" i presume relative to the "first signal". so let's call the first signal x1(t) and the second one x2(t). and let's also define a window function w(t) that is centered at t=0. Im{ w(t) } = 0 w(t) >= 0 w(-t) = w(t) w(t) = 0 for |t| > W so in the vicinity of time t0, we want to know how much x2(t) is delayed from x1(t). so compute (using some discrete-time approximation to integrals): +inf R(tau, t0) = integral{ (x2(t)*w(t-t0)) * x1(t-tau) dt} -inf look for the value of tau that maximizes R(tau) for a fixed t0. that's how much time x1(t) precedes x2(t). it's insensitive to amplitude/gain differences, does not need any periodicity or sinusoidality or any other notion that might make sense for the analytic signal. no FFT. no worrying about phase wrapping. no fiddling. if there is a component of x1(t) that is correlated to x2(t), this should tell you the time lag that makes this correlation the strongest. i dunno. maybe there's something basic i am missing, but it looks like Deadsville around here, so i thought i might mix it up a little. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●September 6, 20132013-09-06
robert bristow-johnson <rbj@audioimagination.com> writes:> On 9/5/13 10:48 AM, radams2000@gmail.com wrote: >> I would suggest; >> >> 1) compute the analytic signal for each of your inputs in the time domain, using either FIR or IIR parallel filters. >> >> 2) compute the magnitude of each of the complex signals computed above. >> >> 3) search for the maximum cross- correlation for the magnitude signals computed above. >> >> 4) if you need better than 1-sample accuracy then find the true peak using quadratic interpolation around the peak (posted here on comp.dsp many times). >> >> I have to admit that I'm guessing that using the analytic envelope would give a better result than using the signal itself. I have more neurons in my gut than in my brain. >> > On 9/5/13 11:35 AM, radams2000@gmail.com wrote: >> Of course if you have the dsp power to do frequency-domain >> processing then that's the best choice, just take the fft of both >> signals, convert to polar, subtract phases and divide by bin >> frequency to get a delay estimate per bin, then average all those >> delays together. If the signal is very long then break into windowed >> segments. >> > > i don't see the use for doing this in the frequency domain at all. > the OP says that the "second signal [has] different amount of delay at > different points" i presume relative to the "first signal". > > so let's call the first signal x1(t) and the second one x2(t). and > let's also define a window function w(t) that is centered at t=0. > > Im{ w(t) } = 0 > w(t) >= 0 > w(-t) = w(t) > w(t) = 0 for |t| > W > > so in the vicinity of time t0, we want to know how much x2(t) is > delayed from x1(t). so compute (using some discrete-time > approximation to integrals): > > +inf > R(tau, t0) = integral{ (x2(t)*w(t-t0)) * x1(t-tau) dt} > -inf > > look for the value of tau that maximizes R(tau) for a fixed t0.... that maximizes R(tau, t0) for a specific t0 ...> that's how much time x1(t) precedes x2(t).i think that should be how much time x2(t) precedes x1(t), or, equivalently, how much x1(t) lags x2(t).> it's insensitive to amplitude/gain differences, does not need any > periodicity or sinusoidality or any other notion that might make sense > for the analytic signal. no FFT. no worrying about phase wrapping. no > fiddling. > > if there is a component of x1(t) that is correlated to x2(t), this > should tell you the time lag that makes this correlation the > strongest.but one point is that your algorithm will have a practical limit on how far we can search in tau. also, how fine do you need t0? only to a nearest sample, or will you need to fractionally resample?> i dunno. maybe there's something basic i am missing, but it looks > like Deadsville around here, so i thought i might mix it up a little.i sorta thought the same thing - why not a basic correlator? -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com






