[PD] Cross correlation using FFT

Charles Henry czhenry at gmail.com
Mon Apr 17 17:24:24 CEST 2006


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

On 4/7/06, Mathieu Bouchard <matju at artengine.ca> wrote:
> On Fri, 7 Apr 2006, Mathieu Bouchard wrote:
> > On Fri, 7 Apr 2006, Mathieu Bouchard wrote:
> > > no, the case when imaginaries cancel happens only when you multiply a
> > > number by its own conjugate, and then it gives the square of the
> > > magnitude:
> > > (x + ix')(y - iy') =  xy + xiy' + ix'y - ix'iy'
> > >                    = (xy + x'y') + (xy' + x'y)i
> > That and the ordinary complex product should be abstractions, but Miller
> > doesn't seem to use abstractions much in his patches (see his FFT
> > tutorials...), so the two kinds of complex products are copypasted all
> > over the place instead. Four [*~], one [+~], one [-~], and eight more
> > wires than using an abstr. Brilliant.
>
> D'OH, typo:
>
> (x + ix')(y - iy') =  xy - xiy' + ix'y - ix'iy'
>                    = (xy + x'y') + (x'y - xy')i
>
>  _ _ __ ___ _____ ________ _____________ _____________________ ...
> | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju
> | Freelance Digital Arts Engineer, Montréal QC Canada
>
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
>


--
Charles Zachary Henry

anti.dazed.med
Med student who needs a Mickey's
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xcorr~.c
Type: text/x-csrc
Size: 2389 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20060417/504c8008/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: intbb~.c
Type: text/x-csrc
Size: 1649 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20060417/504c8008/attachment-0001.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: maxm~.c
Type: text/x-csrc
Size: 3016 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20060417/504c8008/attachment-0002.c>


More information about the Pd-list mailing list