Forums

Cross Correlation & Accuracy

Started by Paul Auchon February 16, 2006
i've implemented a cross correlation algorithm for an audio software, but
the values i find aren't accurate enough for the use i need.


For example, using -exactly- the same signal delayed by 1024 samples (at
44100 Hz samplerate) i find results between 985 and 1020, never 1024, and
sometimes totally wrong values. I used buffers of 262144 samples (6 sec)
to 1048576 samples (24 sec), which seems long enough to me.


I've tried first the normal cross correlation, and then the FFT one with
approximatively the same results.


My question is : could there be a problem with my implementation or is the
accuracy good enough for correlation.

In the affirmative, does other algorithms more accurate exists ? and what
are they.


thanks a lot.


"Paul Auchon" <thewarden@techemail.com> wrote in message 
news:OYSdnTY9iquG52nenZ2dnUVZ_tudnZ2d@giganews.com...
> i've implemented a cross correlation algorithm for an audio software, but > the values i find aren't accurate enough for the use i need. > > > For example, using -exactly- the same signal delayed by 1024 samples (at > 44100 Hz samplerate) i find results between 985 and 1020, never 1024, and > sometimes totally wrong values. I used buffers of 262144 samples (6 sec) > to 1048576 samples (24 sec), which seems long enough to me. >
When you say *exactly* the same signal, do you mean exactly the same samples or a new set of samples of the "same" signal? There is no reason that the same samples should give sloppy results - except for a couple of things: - there is a real SNR associated with quantization - the actual autocorrelation function has a broad peak that is obscured by the noise. If there's a broad peak then that tells you something about the ability to get temporal resolution. The ability to get temporal resolution is a function of the time-bandwidth product of the signal. A tone burst has a time-bandwidth product of 1.0 and has temporal resolution equivalent to the length of the pulse. This is defined as follows: The bandwidth of a tone burst is roughly the reciprocal of the length of the burst. B=1/T so BT=1. If you try to do edge detection of the tone burst for finer temporal resolution then you are relying on higher frequency components and are defining the tone burst to have a higher bandwidth than stated above. Thus, BT is higher and temporal resolution is better. System bandwidth and SNR come into the picture..... What is the BT product of the signal? What does a pure autocorrelation function of the signal look like? Is the peak sharply defined or is it quite broad? Fred
>When you say *exactly* the same signal, do you mean exactly the same
samples
>or a new set of samples of the "same" signal?
the exact same samples, not resampled signal.
> >What is the BT product of the signal? >
i figured out i was testing the algorithm with always the same kind of sounds, so i tried with a 3 second sweep covering the whole spectrum, and i got nearly perfect results. Going further, i tried to eq the incoming sampled sound (that gave poor results before) to the spectrum of a white noise before processing the buffers, and the resulting delay estimation was much better (1-2 samples error). is that treatment called pre whitening filter or something ? i've seen that name around. I will try to look around about it anyhow i'm nearly sure it was the main problem, and hope it will work perfectly soon, thanks a lot. Paul
"Paul Auchon" <thewarden@techemail.com> wrote in message
news:_uOdnTteZ8m-CmneRVn-oQ@giganews.com...
> >
You cannot get good results from ordinary cross correlation unless the signals are white. You need generalised cross corelation (GCC) based on a special weighting in the frequency domain.There is a large literature on this. Tam
Just forget about using auto/cross-correlation for signal period
estimation...

Go to http://www.soundmathtech.com/pitch for an ICASSP paper and Matlab
demo.

And read the US patent application (Pub. Number 20030088401) at
http://www.uspto.gov/patft (strictly non-commercial license)

Start reading it now and put all other papers on the subject where they
belong - in a garbage can :-)


Paul Auchon wrote:
> i've implemented a cross correlation algorithm for an audio software, but > the values i find aren't accurate enough for the use i need. > > > For example, using -exactly- the same signal delayed by 1024 samples (at > 44100 Hz samplerate) i find results between 985 and 1020, never 1024, and > sometimes totally wrong values. I used buffers of 262144 samples (6 sec) > to 1048576 samples (24 sec), which seems long enough to me. > > > I've tried first the normal cross correlation, and then the FFT one with > approximatively the same results. > > > My question is : could there be a problem with my implementation or is the > accuracy good enough for correlation. > > In the affirmative, does other algorithms more accurate exists ? and what > are they. > > > thanks a lot.