Hey,

I am looking to use the cross correlation function to find the delay between two

signals.. I am a bit confused by the output of the function.. The vdsp manual says

"The signals to be correlated are given by the input vectors samples_x[]

and samples_y[]. The length of the input vectors is given by

sample_length. The functions return the result in the array correlation

with lags elements."

What is the correlation array and lags elements? I thought it would just return a shift

size to the maximum correlation between the two signals in samples_x and samples_y?

Any help would be great,

Thanks.

Hi,

Generally speaking, the cross correlation is a vector, not a scalar, whose elements are the result of the inner multiplication of the elements of the two input vectors, shifted by a given offset. For every element C[k] in the output vector, its value corresponds to the relative shifting of the input vectors in k positions.

According to the documentation, the Blackfin library function is defined as:

C[k] = 1/n * sum{ A[j] * B[j+k] } (j = 0...n-k-1)

Where A and B and the input vectors of length n, C is the output vector (the cross-correlation). The index k is in the range of 0...(lags-1).

This means that each element in C is the sum of products of the element of A by the shifted elements of B. The shift amount is k.

The result is:

C = {C[0] C[1] C[2] ... C[lags-1]}

Note that this result is somewhat restrictive compared to the more general form, in which vectors A and B are not neccessarily the same length, and B is being shifted all the way from positions -(nb-1) to +(na-1).

In order to find the maximum correlation, you will need to utilize another step, generally a max value finding loop, using the built-in max() function.

HTH.