I think so. MATLAB xcorr 
<http://uk.mathworks.com/help/signal/ref/xcorr.html> implementation accepts 
a maxlag argument, which is probably handy for many people.

I don't think I will write my xcorr version. I will probably take a dirty 
shortcut: calculate the cross correlation only on windowed segments of 
signals. It should give the correct lag anyway.

On Friday, 8 April 2016 14:49:59 UTC+1, Stefan Karpinski wrote:
>
> Would it make sense to have a maxlag keyword option on xcorr to limit how 
> big the lags it considers are?
>
> On Friday, April 8, 2016, DNF <[email protected] <javascript:>> wrote:
>
>> The xcorr function calls the conv function, which again uses fft. If you 
>> know the general structure and length of your signals ahead of time, you 
>> can probably gain some performance by planning the ffts beforehand. I don't 
>> know why it doesn't work for you, but you could have a look in at conv in 
>> dsp.jl.
>>
>> If you *really* want to speed things up, though, you might implement 
>> your own xcorr.  xcorr dominates the runtime in your function, and if you 
>> know an upper bound on the signal lags, you can implement xcorr with a 
>> limited number of lags. By default xcorr calculates for all lags (in your 
>> case that's 2*48000*60-1 ~ 6million lags). If you know that the max lag is 
>> 1 second, you can save ~98% percent of the runtime of xcorr.
>>
>> A couple of other remarks:
>> * There's no need to put type annotations next to the function outputs, 
>> it's just visual noise
>> * Use ct_idx = cld(lₛ, 2) and forget about the mod.
>>
>

Reply via email to