Correlate
Overview
Cross correlation function
Discussion
This module computes the deterministic cross correlation of the signals on its input pins a block at a time. It is very similar to convolution, differing only in the order of the output. The output is computed by $s[n] = \sum_{k=0}^{M-1} x[n+k] y[k]$, where $x[n]$ is on pin 1 with length $M$ and $y[n]$ is on pin 2, also of length $M$. This operation could be generalized to allow different block sizes if needed.
The parameters shape, skip and length allows control of the range of $n$ that gets calculated. Shape is for quick setting of common ranges. shape = 0: sets skip=0, olen=2*M-1 to compute the full correlation shape = 1: sets skip=M/2, olen=M to compute the center part that has the same length as the inputs. shape = 2: leaves skip and olen to be user-defined. skip: starts storing output at $n = \mathit{skip}$ olen: writes only this many output samples, so $\mathit{skip} <= n < \mathit{skip} + \mathit{olen}$.
Type Definition
typedef struct _ModuleCorrelate
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 shape; // Shape of subset to calculate
INT32 skip; // Number of samples of full cross correlation to skip at output
INT32 olen; // Length of output
} ModuleCorrelateClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
shape | int | parameter | 0 | 0 | 0:2 | |
skip | int | parameter | 0 | 0 | 0:63 | samples |
olen | int | parameter | 0 | 63 | 0:63 | samples |
Pins
Input Pins
Name: in0
Description: Input signal 0
Data type: float
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Name: in1
Description: Input signal 1
Data type: float
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: Cross correlation output
Data type: float
MATLAB Usage
File Name: correlate_module.m
M = correlate_module(NAME, SHAPE)
This module implements a partial correlation of the two signals on its
input pins. How much of the correlation to write can be controlled by
the parameters. Also see convolve_module, which is very similar.
Arguments:
NAME - name of the module
SHAPE - enum of standard subset to calculate