Hi chuck,
Thanks a lot for putting this together. I was so near, but yet so far with regard to getting it right.
I hope you don't mind, but I have incorporated your code from xcorr~ into the flib library. I thought this would make sense since there is already cross correlation in there. Now [cc~ f] performs frequency domain cross correlation using your algorithm, cc~ without any arguments (or with a delay time as an argument) performs time domain cross correlation based on work by Phil Bourke. I have also removed the dependency on fftw; you might think this is crazy, but for the moment at least, I'd like to stick with Mayer.
Thanks again for your help.
Jamie
On Mon Apr 17 17:24:24 CEST 2006 Charles Henry wrote:
Sorry it took me so long to send the external and code.....
It just got me thinking that I was doing something really wrong here,
but I think I've got it straightened out now.
The implementation here does a pretty good job of using xcorr~ in
overlapping blocks, like block 256 2.
So, we have the two signals, as described before
sig1 |/\/\/\/\|/\/\/\/\| 2N non-zero samples
sig2 |----/\/\|/\/\----| N non-zero samples, in the middle
We can do a running calculation of the cross-correlation, using
overlapping blocks. (Don't reblock the output, it won't work that
way.)
|/\/\/\/\|/\/\/\/\|
|----/\/\|/\/\----|
|--------|/\/\/\/\|/\/\/\/\|
|--------|----/\/\|/\/\----|
And the result is that when we add up the results of xcorr across
blocks we get a running calculation of the cross correlation.
So, I also created two others to help here. intbb~ which integrates
(stably) between blocks (which was no doubt unnecessary)
and maxm~ which picks out the maximum value, and its location in the
vector between bounds, e.g. [maxm~ -256 256] picks out the location of
the maximum value, closest to the "origin" of the vector, in either
the last 256 samples of xcorr~ or the first 256 samples of xcorr~
again sorry for the long delay
chuck