File Exchange

image thumbnail

Precedence-based cross-correlograms

version (150 KB) by Christopher Hummersone
Calculate cross-correlograms with a wide range of options

1 Download

Updated 05 May 2018

From GitHub

View Version History

View license on GitHub

NOTE: this function is now available from the IoSR Matlab Toolbox as iosr.auditory.chXcorr.
Calculate cross-correlograms with a wide range of options.
ccg = ch_xcorr(hc_L,hc_R,fs)
ccg = ch_xcorr(hc_L,hc_R,fs,'parameter',value)
[ccg,ic] = ch_xcorr(...)

ccg = ch_xcorr(hc_L,hc_R,fs) cross-correlates the input
2-D matrices hc_L and hc_R over 10ms frame with a
maximum lag of 1ms. 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. ccg has dimensions
[lag,frequency,frame]. The function calculates running
cross-correlations for every sample and integrates these
cross-correlations over each frame. The number of
frames frame_count is calculated thus:

frame_count = ...

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

ccg = ch_xcorr(hc_L,hc_R,fs,'parameter',value) allows a
number of options to be specified. The options are:

({} indicates the default value)

'frame_length' : {round(0.01*fs)} | scalar
The length of frames used to calculate for
integrating cross-correlations.
'noverlap' : {1} | scalar
The number of frames over which to integrate the
cross-correlations. Note that the frame count is
reduced accordingly.
'maxlag' : {round(0.001*fs)} | scalar
The maximum lag of the cross-correlation.
'tau' : {round(0.01*fs)} | scalar
The time constant of the exponential window used to
calculate running cross-correlations.
'inhib' : {[]} | array
Specificies an array with which to multiply the
cross-correlations before they are integrated. The
value defaults to an empty array, meaning that no
inhibition will be applied.
'ic_t' : {0} | scalar
Specifies the interaural coherence (IC) threshold.
Only samples for which the IC exceeds this threshold
will be used to integrate cross-correlations. The
algorithm calculates Interaural Coherence (IC)
according to [1]. The value should be in the range
'norm_flag' : {0} | scalar
Specifies whether the cross-correlograms are
calculated using normalised cross-correlations. A
non-zero value indicates that normalised
cross-correlations are used.
'inhib_mode' : {'subtract'} | 'multiply'
Specify how the inhibition is applied. The default
'subtract' will subtract inhib from the running
cross-correlations; 'multiply' will multiply inhib
with the running cross-correlations.

[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


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.

Further Reading

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.

Cite As

Christopher Hummersone (2021). Precedence-based cross-correlograms (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!