You are on page 1of 14

1.

Source detection: Correlate the output of one microphone with an expected sound signature
or with another microphone using generalized cross-correlation (GCC) [5].
2. Bearing determination: Once correlated, determine the exact bearing of the sound source
using time difference of arrival (TDOA). // melihat posisi dg waktu datangnya suara
3. Triangulation: Use the bearings of two or more arrays to triangulate the exact position of
the sound source. // deteksi dg sudut

TY - JOUR
AU - Jin, Jungdong
AU - Jin, Seunghun
AU - Lee, SangJun
AU - Kim, Hyung
AU - Choi, Jong
AU - Kim, Munsang
AU - Jeon, Jae
PY - 2014/04/30
SP - 175
EP - 183
N2 - In this paper, we present the design and implementation of real-time sound localization
based on 0.13 _m CMOS process. Time delay of arrival (TDOA) estimation was used to
obtain the direction of the sound signal. The sound localization chip consists of four modules:
data buffering, short-term energy calculation, cross correlation, and azimuth calculation. Our
chip achieved real-time processing speed with full range (360°) using three microphones.
Additionally, we developed a dedicated sound localization circuit (DSLC) system for
measuring the accuracy of the sound localization chip. The DSLC system revealed that our
chip gave reasonably accurate results in an experiment that was carried out in a noisy and
reverberant environment. In addition, the performance of our chip was compared with those
of other chip designs.
T1 - Real-time Sound Localization Using Generalized Cross Correlation Based on 0.13 ㎛
CMOS Process
VL - 14
DO - 10.5573/JSTS.2014.14.2.175
JO - JSTS:Journal of Semiconductor Technology and Science
ER -

Due to hard- and software progress applications based on sound enhancement are gaining
popularity. But such applications are often still limited by hardware costs, energy and real-time
constraints, thereby bounding the available complexity. One task often accompanied with
(multichannel) sound enhancement is the localization of the sound source. This paper focusses
on implementing an accurate Sound Source Localizer (SSL) for estimating the position of a
sound source on a digital signal processor, using as less CPU resources as possible. One of the
least complex algorithms for SSL is a simple correlation, implemented in the frequency-domain
for efficiency, combined with a frequency bin weighing for robustness. Together called
Generalized Cross Correlation (GCC). One popular weighing called GCC PHAse Transform
(GCC-PHAT) will be handled. In this paper it is explained that for small microphone arrays this
frequency-domain implementation is inferior to its time-domain alternative in terms of algorithmic
complexity. Therefore a time-domain PHAT equivalent will be described. Both implementations
are compared in terms of complexity (clock cycles needed on a Texas Instruments C5515 DSP)
and obtained results, showing a complexity gain with a factor of 146, with hardly any loss in
localization accuracy.
Source Localization Using Generalized Cross
Correlation
Try it in MATLAB

This example shows how to determine the position of the source of a wideband signal
using generalized cross-correlation (GCC) and triangulation. For simplicity, this example is
confined to a two-dimensional scenario consisting of one source and two receiving
sensor arrays. You can extend this approach to more than two sensors or sensor arrays
and to three dimensions.

Introduction
Source localization differs from direction-of-arrival (DOA) estimation. DOA estimation
seeks to determine only the direction of a source from a sensor. Source localization
determines its position. In this example, source localization consists of two steps, the first
of which is DOA estimation.

1. Estimate the direction of the source from each sensor array using a DOA estimation
algorithm. For wideband signals, many well-known direction of arrival estimation
algorithms, such as Capon's method or MUSIC, cannot be applied because they
employ the phase difference between elements, making them suitable only for
narrowband signals. In the wideband case, instead of phase information, you can use
the difference in the signal's time-of-arrival among elements. To compute the time-
of-arrival differences, this example uses the generalized cross-correlation with phase
transformation (GCC-PHAT) algorithm. From the differences in time-of-arrival, you
can compute the DOA. (For another example of narrowband DOA estimation
algorithms, see High Resolution Direction of Arrival Estimation).

2. Calculate the source position by triangulation. First, draw straight lines from the
arrays along the directions-of-arrival. Then, compute the intersection of these two
lines. This is the source location. Source localization requires knowledge of the
position and orientation of the receiving sensors or sensor arrays.
Triangulation Formula
The triangulation algorithm is based on simple trigonometric formulas. Assume that the
sensor arrays are located at the 2-D coordinates (0,0) and (L,0) and the unknown source
location is (x,y). From knowledge of the sensor arrays positions and the two directions-of-
arrival at the arrays, θ1 and θ2, you can compute the (x,y) coordinates from

L=ytanθ1+ytanθ2

which you can solve for y


y=L/(tanθ1+tanθ2)

and then for x

x=ytanθ1

The remainder of this example shows how you can use the functions and System objects
of the Phased Array System Toolbox™ to compute source position.

Source and Sensor Geometry


Set up two receiving 4-element ULAs aligned along the x-axis of the global coordinate
system and spaced 50 meters apart. The phase center of the first array is (0,0,0) . The
phase center of the second array is (50,0,0) . The source is located at (30,100) meters. As
indicated in the figure, the receiving array gains point in the +y direction. The source
transmits in the -y direction.

Specify the baseline between sensor arrays.

L = 50;

Create a 4-element receiver ULA of omnidirectional microphones. You can use the
same phased.ULA System object™ for
the phased.WidebandCollector and phased.GCCEstimator System objects for both arrays.

N = 4;
rxULA = phased.ULA('Element',phased.OmnidirectionalMicrophoneElement,...
'NumElements',N);
Specify the position and orientation of the first sensor array. When you create a ULA, the
array elements are automatically spaced along the y-axis. You must rotate the local axes
of the array by 90° to align the elements along the x-axis of the global coordinate system.

rxpos1 = [0;0;0];
rxvel1 = [0;0;0];
rxax1 = azelaxes(90,0);

Specify the position and orientation of the second sensor array. Choose the local axes of
the second array to align with the local axes of the first array.

rxpos2 = [L;0;0];
rxvel2 = [0;0;0];
rxax2 = rxax1;

Specify the signal source as a single omnidirectional transducer.

srcpos = [30;100;0];
srcvel = [0;0;0];
srcax = azelaxes(-90,0);
srcULA = phased.OmnidirectionalMicrophoneElement;

Define Waveform
Choose the source signal to be a wideband LFM waveform. Assume the operating
frequency of the system is 300 kHz and set the bandwidth of the signal to 100 kHz.
Assume a maximum operating range of 150 m. Then, you can set the pulse repetition
interval (PRI) and the pulse repetition frequency (PRF). Assume a 10% duty cycle and set
the pulse width. Finally, use a speed of sound in an underwater channel of 1500 m/s.

Set the LFM waveform parameters and create the phased.LinearFMWaveform System
object™.

fc = 300e3; % 300 kHz


c = 1500; % 1500 m/s
dmax = 150; % 150 m
pri = (2*dmax)/c;
prf = 1/pri;
bw = 100.0e3; % 100 kHz
fs = 2*bw;
waveform = phased.LinearFMWaveform('SampleRate',fs,'SweepBandwidth',bw,...
'PRF',prf,'PulseWidth',pri/10);

The transmit signal can then be generated as

signal = waveform();

Radiate, Propagate, and Collect Signals


Modeling the radiation and propagation for wideband systems is more complicate than
modeling narrowband systems. For example, the attenuation depends on frequency. The
Doppler shift as well as the phase shifts among elements due to the signal incoming
direction also vary according to the frequency. Thus, it is critical to model those behaviors
when dealing with wideband signals. This example uses a subband approach.
Set the number of subbands to 128.

nfft = 128;

Specify the source radiator and the sensor array collectors.

radiator = phased.WidebandRadiator('Sensor',srcULA,...
'PropagationSpeed',c,'SampleRate',fs,...
'CarrierFrequency',fc,'NumSubbands',nfft);
collector1 = phased.WidebandCollector('Sensor',rxULA,...
'PropagationSpeed',c,'SampleRate',fs,...
'CarrierFrequency',fc,'NumSubbands',nfft);
collector2 = phased.WidebandCollector('Sensor',rxULA,...
'PropagationSpeed',c,'SampleRate',fs,...
'CarrierFrequency',fc,'NumSubbands',nfft);

Create the wideband signal propagators for the paths from the source to the two sensor
arrays.

channel1 = phased.WidebandFreeSpace('PropagationSpeed',c,...
'SampleRate',fs,'OperatingFrequency',fc,'NumSubbands',nfft);
channel2 = phased.WidebandFreeSpace('PropagationSpeed',c,...
'SampleRate',fs,'OperatingFrequency',fc,'NumSubbands',nfft);

Determine the propagation directions from the source to the sensor arrays. Propagation
directions are with respect to the local coordinate system of the source.

[~,ang1t] = rangeangle(rxpos1,srcpos,srcax);
[~,ang2t] = rangeangle(rxpos2,srcpos,srcax);

Radiate the signal from the source in the directions of the sensor arrays.

sigt = radiator(signal,[ang1t ang2t]);

Then, propagate the signal to the sensor arrays.

sigp1 = channel1(sigt(:,1),srcpos,rxpos1,srcvel,rxvel1);
sigp2 = channel2(sigt(:,2),srcpos,rxpos2,srcvel,rxvel2);

Compute the arrival directions of the propagated signal at the sensor arrays. Because the
collector response is a function of the directions of arrival in the sensor array local
coordinate system, pass the local coordinate axes matrices to the rangeangle function.

[~,ang1r] = rangeangle(srcpos,rxpos1,rxax1);
[~,ang2r] = rangeangle(srcpos,rxpos2,rxax2);

Collect the signal at the receive sensor arrays.

sigr1 = collector1(sigp1,ang1r);
sigr2 = collector2(sigp2,ang2r);

GCC Estimation and Triangulation


Create the GCC-PHAT estimators.

doa1 = phased.GCCEstimator('SensorArray',rxULA,'SampleRate',fs,...
'PropagationSpeed',c);
doa2 = phased.GCCEstimator('SensorArray',rxULA,'SampleRate',fs,...
'PropagationSpeed',c);
Estimate the directions of arrival.

angest1 = doa1(sigr1);
angest2 = doa2(sigr2);

Triangulate the source position use the formulas established previously. Because the
scenario is confined to the x-y plane, set the z-coordinate to zero.

yest = L/(abs(tand(angest1)) + abs(tand(angest2)));


xest = yest*abs(tand(angest1));
zest = 0;
srcpos_est = [xest;yest;zest]
srcpos_est = 3×1

29.9881
100.5743
0

The estimated source location matches the true location to within 30 cm.

Summary
This example showed how to perform source localization using triangulation. In
particular, the example showed how to simulate, propagate, and process wideband
signals. The GCC-PHAT algorithm is used to estimate the direction of arrival of a
wideband signal.

Hi all,

Im working on a project related to localization and tracking through digital signal processing
with the generalized cross-correlation phase transform (GCC-PHAT) algorithm and facing a
problem of not knowing what to do.

my system consists of 6 microphones with amplifiers and low pass filters to remove aliasing,
a Raspberry Pi, two servos.

the raspberry pi has no analog inputs so i thought of using ADCs, the samples must be
synchronized so im looking for a simultaneous sampling ADC with 4-6 channels and 10-12
bits resolution, the maximum sampling frequency per channel must be low lets say about
8ksps/channel ( i dont know if i can control the sampling rate and if i can then how to do it? if
a chip has 480ksps/channel can i control this value? )

im a newbie in hardware and embedded systems, but alot of people told me that the
raspberry pi wont work at those rates (something about the SPI driver of the raspberry pi and
its latency) and told me to use a DSP chip but i dont know which one is suitable for my
application.

im looking for an ADC with those specifications and a suitable DSP chip to perform the
processing(FFT, IFFT and least square estimation) and pass the data to the raspberry pi to
control the motors , if the pi cant handle those data rates then any DSP chip is suitable as
long it can process those signals and control the two servos
gccphat

Generalized cross-correlation

collapse all in page

Syntax
tau = gccphat(sig,refsig)

tau = gccphat(sig,refsig,fs)

[tau,R,lag] = gccphat(___)

[___] = gccphat(sig)

[___] = gccphat(sig,fs)

Description
example

tau = gccphat(sig,refsig) computes the time delay, tau, between the signal, sig, and a
reference signal, refsig. Both sig and refsig can have multiple channels. The function
assumes that the signal and reference signal come from a single source. To estimate the
delay, gccphat finds the location of the peak of the cross-correlation
between sig and refsig. The cross-correlation is computed using the generalized cross-
correlation phase transform (GCC-PHAT) algorithm. Time delays are multiples of the
sample interval corresponding to the default sampling frequency of one hertz.

example

tau = gccphat(sig,refsig,fs), specifies the sampling frequency of the signal. Time


delays are multiples of the sample interval corresponding to the sampling frequency. All
input signals should have the same sample rate.

example

[tau,R,lag] = gccphat(___) returns, in addition, the cross-correlation values and


correlation time lags, using any of the arguments from previous syntaxes. The lags are
multiples of the sampling interval. The number of cross-correlation channels equals the
number of channels in sig.

example

[___] = gccphat(sig) or [___] = gccphat(sig,fs) returns the estimated delays and cross
correlations between all pairs of channels in sig. If sig has M columns, the
resulting tau and R have M2 columns. In these syntaxes, no reference signal input is used.
The first M columns of tau and R contain the delays and cross correlations that use the
first channel as the reference. The second M columns contain the delays and cross-
correlations that use the second channel as the reference, and so on.

Examples
collapse all

Cross-Correlation Between Two Signals and Reference Signal


Try it in MATLAB

Load a gong sound signal. First, use the gong signal as a reference signal. Then, duplicate
the signal twice, introducing time delays of 5 and 25 seconds. Leave the sampling rate to
its default of one hertz. Use gccphat to estimate the time delays between the delayed
signals and the reference signal.

load gong;
refsig = y;
delay1 = 5;
delay2 = 25;
sig1 = delayseq(refsig,delay1);
sig2 = delayseq(refsig,delay2);
tau_est = gccphat([sig1,sig2],refsig)
tau_est = 1×2

5 25

Cross-Correlation Between Signal and Reference Signal


Try it in MATLAB

Load a gong sound signal. Use the gong signal as a reference signal. Then, duplicate the
signal, introducing a time delays of 5 milliseconds. Use the sampling rate of 8192 Hz.
Use gccphat to estimate the time delay between the delayed signal and the reference
signal.

load gong;
delay = 0.005;
refsig = y;
sig = delayseq(refsig,delay,Fs);
tau_est = gccphat(sig,refsig,Fs)
tau_est = 0.0050
Plot Cross-Correlation of Three Signals with Reference Signal
Try it in MATLAB

Load a musical sound signal with a sample rate is 8192 hertz. Then, duplicate the signal
three times and introduce time delays between the signals. Estimate the time delays
between the delayed signals and the reference signals. Plot the correlation values.

load handel;
dt = 1/Fs;
refsig = y;
Create three delayed versions of the signal.
delay1 = -5.2*dt;
delay2 = 10.3*dt;
delay3 = 7*dt;
sig1 = delayseq(refsig,delay1,Fs);
sig2 = delayseq(refsig,delay2,Fs);
sig3 = delayseq(refsig,delay3,Fs);
Cross-correlate the delayed signals with the reference signal.

[tau_est,R,lags] = gccphat([sig1,sig2,sig3],refsig,Fs);
The gccphat functions estimates the delay to the nearest sample interval.

disp(tau_est*Fs)
-5 10 7
Plot the correlation functions.

plot(1000*lags,real(R(:,1)))
xlabel('Lag Times (ms)')
ylabel('Cross-correlation')
axis([-5,5,-.4,1.1])
hold on
plot(1000*lags,real(R(:,2)))
plot(1000*lags,real(R(:,3)))
hold off

Plot Cross-Correlation of Several Signals


Try it in MATLAB

Load a musical sound signal with a sample rate is 8192 hertz. Then, duplicate the signal
two times and introduce time delays between the two signals and the reference signal.
Estimate the time delays and plot the cross-correlation function between all pairs of
signals.

load handel;
dt = 1/Fs;
refsig = y;
Create three delayed versions of the signal.

delay1 = -5.7*dt;
delay2 = 10.2*dt;
sig1 = delayseq(refsig,delay1,Fs);
sig2 = delayseq(refsig,delay2,Fs);
Cross-correlate all signals with the other signal.

[tau_est,R,lags] = gccphat([refsig,sig1,sig2],Fs);
Show the time delays in units of sample interval. The algorithm estimates time delays
quantized to the nearest sample interval. Cross-correlation of three signals produce 9
possible time delays, one for each possible signal pair.

disp(tau_est*Fs)
0 -6 10 6 0 16 -10 -16 0
A signal correlated with itself gives zero lag.

Plot the correlation functions.

for n=1:9
plot(1000*lags,real(R(:,n)))
if n==1
hold on
xlabel('Lag Times (ms)')
ylabel('Correlation')
axis([-5,5,-.4,1.1])
end
end
hold off
Input Arguments
collapse all
sig— Sensor signals
N-by-1 complex-valued column vector | N-by-M complex-valued
matrix
Sensor signals, specified as an N-by-1 column vector or an N-by-M matrix. N is the
number of time samples and M is the number of channels. If sig is a matrix, each column
is a different channel.

Example: [0,1,2,3,2,1,0]

Data Types: single | double


Complex Number Support: Yes

— Reference sensor signals


refsig
N-by-1 complex-valued column vector | N-by-M complex-valued
matrix
Reference signals, specified as an N-by-1 complex-valued column vector or an N-by-
M complex-valued matrix. If refsig is a column vector, then all channels
in sig use refsig as the reference signal when computing the cross-correlation.
If refsig is a matrix, then the size of refsig must match the size of sig.
The gccphat function computes the cross-correlation between corresponding channels
in sig and refsig. The signals can come from different sources.

Example: [1,2,3,2,1,0,0]

Data Types: single | double


Complex Number Support: Yes

fs — Signal sample rate


1 (default) | positive real-valued scalar
Signal sample rate, specified as a positive real-valued scalar. All signals should have the
same sample rate. Sample rate units are in hertz.

Example: 8000

Data Types: single | double


Complex Number Support: Yes

Output Arguments
collapse all

tau— Time delay


1-by-K real-valued row vector
Time delay, returned as a 1-by-K real-valued row vector. The value of K depends upon
the input argument syntax.

 When a reference signal, refsig, is used, the value of K equals the column dimension
of sig, M. Each entry in tau specifies the estimated delay for the corresponding signal
pairs in sig and refsig.

 When no reference signal is used, the value of K equals the square of the column
dimension of sig, M2. Each entry in tau specifies the estimated delay for the
corresponding signal pairs in sig.

Units are seconds.

R — Cross-correlation between signals


(2N+1)-by-K complex-valued matrix
Cross-correlation between signals at different sensors, returned as a (2N+1)-by-
K complex-valued matrix.

 When a reference signal, refsig, is used, the value of K equals the column dimension
of sig, M. Each column is the cross-correlation between the corresponding signal pairs
in sig and refsig.
 When no reference signal is used, the value of K equals the square of the column
dimension of sig, M2. Each column is the cross-correlation between the corresponding
signal pairs in sig.

lag— Cross-correlation lag times


(2N+1) real-valued column vector
Correlation lag times, returned as a (2N+1) real-valued column vector. Each row
of lag contains the lag time for the corresponding row of R. Lag values are constrained to
be multiples of the sampling interval. Lag units are in seconds.

More About
collapse all
Generalized Cross-Correlation
You can use generalized cross-correlation to estimate the time difference of arrival of a
signal at two different sensors.

A model of a signal emitted by a source and received at two sensors is given by:

r1(t)=s(t)+n1(t)r2(t)=s(t−D)+n2(t)

where D is the time difference of arrival (TDOA), or time lag, of the signal at one sensor
with respect to the arrival time at a second sensor. You can estimate the time delay by
finding the time lag that maximizes the cross-correlation between the two signals.

From the TDOA, you can estimate the broadside arrival angle of the plane wave with
respect to the line connecting the two sensors. For two sensors separated by distance L,
the broadside arrival angle, Broadside Angles, is related to the time lag by

sinβ=
cτL

where c is the propagation speed in the medium.

A common method of estimating time delay is to compute the cross-correlation between


signals received at two sensors. To identify the time delay, locate the peak in the cross-
correlation. When the signal-to-noise ratio (SNR) is large, the correlation peak, τ,
corresponds to the actual time delay D.

{ }
R(τ)=E r1(t)r2(t+τ) ˆD = R(τ)
argmaxτ
When the correlation function is more sharply peaked, performance improves. You can
sharpen a cross correlation peak using a weighting function that whitens the input
signals. This technique is called generalized cross-correlation (GCC). One particular
weighting function normalizes the signal spectral density by the spectrum magnitude,
leading to the generalized cross-correlation phase transform method (GCC-PHAT).
 
−i2πfτ
S(f)= R(τ)e dτ˜R(τ)= e+i2πfτdf˜D = ˜R(τ)
∞−∞ ∞−∞S(f)S(f) argmaxτ
If you use just two sensor pairs, you can only estimate the broadside angle of arrival.
However, if you use multiple pairs of non-collinear sensors, for example, in a URA, you
can estimate the arrival azimuth and elevation angles of the plane wave using least-
square estimation. For N sensors, you can write the delay time τkj of a signal arriving at
the kth sensor with respect to the jth sensor by

( )
cτkj=− →xk−→xj ⋅→u→u=cosαsinθˆi+sinαsinθˆj+cosθˆk
where u is the unit propagation vector of the plane wave. The angles α and θ are the
azimuth and elevation angles of the propagation vector. All angles and vectors are
defined with respect to the local axes. You can solve the first equation using least-
squares to yield the three components of the unit propagation vector. Then, you can
solve the second equation for the azimuth and elevation angles.

References
[1] Knapp, C. H. and G.C. Carter, “The Generalized Correlation Method for Estimation of
Time Delay.” IEEE Transactions on Acoustics, Speech and Signal Processing. Vol. ASSP-
24, No. 4, Aug 1976.

[2] G. C. Carter, “Coherence and Time Delay Estimation.” Proceedings of the IEEE. Vol.
75, No. 2, Feb 1987.

You might also like