On Sun, 17 Jun 2007, Tania Habib wrote:
I was wondering if some body can tell me if there is an object to generate the cross correlation of two signals. If there is, please let me know which library has it.
Do it with [fft~] just like for signal convolution, except that in computing the [*~]s you replace the [-~] by a [+~].
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
Mathieu's right here... It can be done with abstractions. I'm not sure that mine are all correct, but I've used this technique a couple times without making complete abstractions for it... Here's an abstraction for computing a symmetric cross-covariance, this way. It outputs the cross-covariance, xcov(k)=sum(i=-32,...,31; s1(i+k)*s2(i)) It's still pretty ugly, and the details of the math confuse me a bit. I'm still working on the one-sided cross covariance function for delays, like from [0,63] instead of [-32,31]
This one works within block sizes of 64, by using an [block~ 128 2] . It is formatted very tricky using lrshift, but I think you will see that it's continuous. The test patch uses zexy for z~. If you want to compute xcov on larger block sizes, just change all the numbers according to the size you need.
Do you think I've got it right? Should the output be reversed? This abstraction also could be improved to make running calculations of cross-correlation, which add up the variance in s1 and s2 and normalize the output.
Jamie Bullock has cc~ in his flib collection. It computes cross correlation in the time domain, and cross-covariance using the freq. domain. I worked on it a while back...but have been lazy about trying to change the cross-covariance into a cross-correlation. Sorry, Jamie.
Chuck
On 6/17/07, Mathieu Bouchard matju@artengine.ca wrote:
On Sun, 17 Jun 2007, Tania Habib wrote:
I was wondering if some body can tell me if there is an object to generate the cross correlation of two signals. If there is, please let me know which library has it.
Do it with [fft~] just like for signal convolution, except that in computing the [*~]s you replace the [-~] by a [+~].
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada _______________________________________________ PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Here's an abstraction for computing a symmetric cross-covariance, this way. It outputs the cross-covariance, xcov(k)=sum(i=-32,...,31; s1(i+k)*s2(i)) It's still pretty ugly, and the details of the math confuse me a bit. I'm still working on the one-sided cross covariance function for delays, like from [0,63] instead of [-32,31]
and here's the same thing except it's a forward cross-covariance, called fxcov~.pd It's pretty much the same thing (up to a certain point), but as I've discovered, using xcov to calculate PSD and CSD for deconvolution can be tricky (even when it's a full rank system). There's a big diff between symmetric and forward cross-covariance in this respect. None of my reverberation measurement patches ever worked completely due to audio dropouts and badly formatted problems (I'm still working on it). The fxcov~ patch contains some math for your comparison.
Chuck
Hi,
On Sun, 2007-06-17 at 23:01 -0500, Charles Henry wrote:
Jamie Bullock has cc~ in his flib collection. It computes cross correlation in the time domain, and cross-covariance using the freq. domain. I worked on it a while back...but have been lazy about trying to change the cross-covariance into a cross-correlation. Sorry, Jamie.
flib is now deprecated, and has been surpassed by libxtract, which is a generic C library that includes as an example a PD external that wraps it's functionality.
It can be found at http://sourceforge.net/projects/libxtract. If you want to use the fft-based autocorrelation you will need the fftw library, and to compile libxtract with --enable-fft.
It includes a time domain and fft-based autocorrelation, but no arbitrary cross correlation functions.
Chuck, I must remember to add your cross-covariance code into libxtract (with acknowledgement of course).
best,
Jamie
This one works within block sizes of 64, by using an [block~ 128 2] .
Now, I've got one where you add an argument and use arbitrary block sizes. It's much more useful, this way. [sxcov~ 2048] works within a blocksize of 2048, and calculates the symmetric cross covariance of two signals.
Still having aggravating time, trying to normalize by the proper calculation of variance on each signal. It might be a while before I get it together.
Chuck
Alright.... here is my last version of the patches. Even if no one else is interested, I consider the problem solved at this point. Whenever the calculations are reset, there is a brief transient. digression: That's because I can't find a way to precisely calculate a signal which represents the sum of squares of s1, as follows: output(k)=sum(i= -32+k:31+k; s1(i)^2) for k=-32:31 in the same block as sxcov~ (I tried to do that first, but no easy solution came up, so I chose something simpler, if only a little less accurate)
anyway, each of the patches from previous posts have been modified and corrected. Hopefully, this method gives you the most flexibility for computing sxcov~ and sxcorr~ in real time with abstractions.
Chuck
On 6/20/07, Charles Henry czhenry@gmail.com wrote:
This one works within block sizes of 64, by using an [block~ 128 2] .
Now, I've got one where you add an argument and use arbitrary block sizes. It's much more useful, this way. [sxcov~ 2048] works within a blocksize of 2048, and calculates the symmetric cross covariance of two signals.
Still having aggravating time, trying to normalize by the proper calculation of variance on each signal. It might be a while before I get it together.
Chuck
On Sun, 17 Jun 2007, Mathieu Bouchard wrote:
On Sun, 17 Jun 2007, Tania Habib wrote:
I was wondering if some body can tell me if there is an object to generate the cross correlation of two signals. If there is, please let me know which library has it.
Do it with [fft~] just like for signal convolution, except that in computing the [*~]s you replace the [-~] by a [+~].
... and you replace the [+~] by a [-~].
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada