Code covered by the BSD License  

Highlights from
Precedence-based cross-correlograms

Be the first to rate this file! 19 Downloads (last 30 days) File Size: 7.52 KB File ID: #27776

Precedence-based cross-correlograms



27 May 2010 (Updated )

Calculate cross-correlograms with a wide range of options

| Watch this File

File Information

CH_XCORR Calculate cross-correlograms with a wide range of options.

  [CCG,IC] = CH_XCORR(...)


CCG = CH_XCORR(HC_L,HC_R,FRAME_COUNT,FRAME_LENGTH,MAXLAG,TAU) calculates cross-correlograms with a range of cross-correlation parameters.

The function cross-correlates the input 2-D matrices HC_L and HC_R over frames of length FRAME_LENGTH. It is assumed that the number of frequency channels is min(size(HC_L)) and hence HC_L and HC_R can be in either orientation. The cross-correlograms consist of cross-correlations for every frame and frequency channel. The function calculates running cross-correlations for every sample and integrates these cross-correlations over NOVERLAP frames. The lags are determined by MAXLAG and the cross-correlation is computed over the range of lags -MAXLAG to MAXLAG, i.e., 2*MAXLAG+1 lags. The number of frames FRAME_COUNT is calculated thus:


The underlying cross-correlation algorithm is based on that proposed by Faller & Merimaa [1]. In this implmentation, the time constant of the backward infinite exponential window is given by TAU (in samples).

CCG = CH_XCORR(...,INHIB) multiplies the running cross-correlations with INHIB before the cross-correlations are averaged. If INHIB is un-specified it is set to ones(size(HC_L)).

CCG = CH_XCORR(...,IC_T,NORM_FLAG) allows an IC threshold to be specified and normalisation to be turned on and off. The algorithm calculates Interaural Coherence (IC) according to [1]. The cross-correlogram is calculated for each frame by averaging only those cross-correlations within the frame for which the corresponding IC exceeds the IC threshold IC_T (0<=IC_T<=1). Setting this value to 0 will result in all cross-correlations contributing to the average (default). This implementation also permits the normalisation to be turned off by specifying NORM_FLAG; a non-zero value means normalisation will be applied (default). This means, for example, that an IC theshold could be employed, but the un-normalised cross-correlations would contribute to the cross-correlograms. Note that either both or neither of these values must be specified.

CCG = CH_XCORR(...,INHIB_MODE) uses the mode INHIB_MODE to apply the inhibition. The options are 'multiply' (default), whereby the inhibitory signal INHIB will be multiplied with the running cross-correlation, or 'subtract', whereby INHIB will be subtracted from the running cross-correlation.

[CCG,IC] = CH_XCORR(...) returns the calculated IC to the matrix IC. Although the matrix returned is the same size as HC_L, IC is only calculated for samples 1:FRAME_COUNT*FRAME_LENGTH, other values will
be set to 0.


See the enclosed documentation for more details on the workings of the algorithm and an important caveat.


[1] C. Faller and J. Merimaa, "Source localization in complex listening situations: Selection of binaural cues based on interaural coherence", The Journal of the Acoustical Society of America, vol. 116, pp.3075-3089, Nov. 2004.


C. Hummersone, R. Mason, and T. Brookes, "A comparison of computational precedence models for source separation in reverberant environments", in 128th Audio Engineering Society Convention, London, May 2010, paper 7981.


Check Whether Mex File Is Compiled For System inspired this file.

MATLAB release MATLAB 7.8 (R2009a)
Other requirements Requires a C compiler. The code should automatically compile using check_mex_compiled (called from the m-file wrapper). Very long signals are discouraged, although I haven't tried any longer than about 5 seconds @ fs=16kHz and 32 frequency channels.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
24 Oct 2010 Christopher Hummersone

whoops, you'll need this file:

27 Jul 2010

Updated the mex function

06 Aug 2010

Fixed an issue with an un-specified max function. Thanks to Lars Bramsløw for pointing it out.

06 Aug 2010

Whoops, fixed another silly mistake, thanks to Lars Bramsløw

21 Oct 2010

Added additional 'NOVERLAP' parameter for integrating over several frames. Added note to documentation on limitations for normalised cross-correlation.

22 Oct 2010

Created additional documentation explaining the algorithm.

26 Oct 2010

Fixed a bug that gave negative numbers when using the 'subtract' option. Updated the documentation accordingly.

11 Nov 2010

removed need to framecount parameter input, now calculated automatically.

18 Apr 2011

Updated check for inhib matrix size and shape

16 Jun 2011

Updated documentation, added verbose comments through source code

04 Aug 2011

Added updated check_mex_compiled.m

17 Aug 2011

Fixed a bug whereby output IC would not be the same size as the input data. Added check to ensure that they are the same size and transposition. Updated help to include dims of output CCG.

18 Jan 2012

Some bug fixes.

26 Jun 2013

Output IC now reflects specified threshold.

Contact us