TDE (Time Delay Estimation)时延估计

最近正在学习AEC,需要完成线性回声消除的一些简单的代码,第一个问题是需要求出输入信号与参考信号之间的时延。因为时延影响了后面AEC算法的效果,所以对整体的回声消除效果比较重要。

一、用互相关的方法完成时延估计

The generalized cross-correlation (GCC) is regarded as the most popular approach for estimating the time difference of arrival (TDOA) between the signals received at two sensors. The GCC of a pair of sensor signals is defined as the inverse Fourier transform of the weighted cross-power spectrum

上面的图片来自:Frequency-Sliding Generalized Cross-Correlation: A Sub-band Time Delay Estimation Approach ----Maximo Cobos, Senior Member, IEEE, Fabio Antonacci, Senior Member, IEEE, Luca Comanducci, Student Member, IEEE, and Augusto Sarti, Senior Member, IEEE

 

GCC TDE用FFT计算的流程:

 

 

互相关法:
                r_{yx}(m) = F^{-1}\left \{ Y(k)X^{*} (k)\right \} = F^{-1}\left \{ P_{yx}(k)\right \}

广义互相关法:延时信息体现在互功率谱的相位上,而与幅度无关。

                r_{xy}(m) = F^{-1}\left \{ \frac{P_{xy}(k))}{|P_{xy}(k)|} \right \}

这种互功率谱加权方式,称为GCC-PHAT(PHAse Transformation),或
CSP(Cross Spectral Phase)。

             

百度百科对互相关的解析:  

        互相关函数是信号分析里的概念,表示的是两个时间序列之间的相关程度,即描述信号x(t),y(t)在任意两个不同时刻t1,t2的取值之间的相关程度。描述两个不同的信号之间的相关性时,这两个信号可以是随机信号,也可以是确知信号。

当计算出来的值等 于 1 的时候,相当于两个信号完美重合,因此可以利用这个信息来求两个信号的延时。

 

互相关 的 矩阵计算:

可以用来计算频域里的互相关

For two random vectors {X} =(X_{1},\ldots ,X_{m})^{\rm {T}}and  {Y} =(Y_{1},\ldots ,Y_{n})^{\rm {T}}, each containing random elements whose expected value and variance exist, the cross-correlation matrix of X and Y  is defined by

{\displaystyle \operatorname {R} _{\mathbf {X} \mathbf {Y} }\triangleq \ \operatorname {E} [\mathbf {X} \mathbf {Y} ^{\rm {T}}]}

and has dimensions {\displaystyle m\times n}.

Written component-wise:

{\displaystyle \operatorname {R} _{\mathbf {X} \mathbf {Y} }={\begin{bmatrix}\operatorname {E} [X_{1}Y_{1}]&\operatorname {E} [X_{1}Y_{2}]&\cdots &\operatorname {E} [X_{1}Y_{n}]\\\\\operatorname {E} [X_{2}Y_{1}]&\operatorname {E} [X_{2}Y_{2}]&\cdots &\operatorname {E} [X_{2}Y_{n}]\\\\\vdots &\vdots &\ddots &\vdots \\\\\operatorname {E} [X_{m}Y_{1}]&\operatorname {E} [X_{m}Y_{2}]&\cdots &\operatorname {E} [X_{m}Y_{n}]\\\\\end{bmatrix}}}

The random vectors and need not have the same dimension, and either might be a scalar value.

 

看完上面对互相关的定义和计算方法,可以看出,要求出两个信号的延迟。可以给定一段时长的信号(例如1S),然后做FFT来计算广义互相关,最后再做傅里叶逆变换找出最大的一个Rxy 的位置, 用这个位置来确定延时,精确到sample.

clear all;

y_fn = '..\audio_data\input.raw'
y_fid = fopen(y_fn,'r');
y = fread(y_fid, 'short', 'ieee-le');
y = y(1:4800) ;
fclose(y_fid);
%sound(y, 16000);

x_fn = '..\audio_data\ref.raw'
x_fid = fopen(x_fn,'r');
x = fread(x_fid, 'short', 'ieee-le');
x = x(1:4800) ;
fclose(x_fid);
%sound(x, 16000);

y_fd = fft(y);
x_fd = fft(x);


P_yx = (y_fd .* conj(x_fd));
P_yx_abs = abs(y_fd .* conj(x_fd));

%R_yx = ifft(P_yx);             %cross-corelation
R_yx = ifft(P_yx ./ P_yx_abs);  %generalized cross-corelation

R_yx = R_yx(1:4800);
[R_yx_max,m_idx] =  max(R_yx);
stem(1:4800, R_yx)
disp(m_idx);

当然matlab 里面已经有提供了gccphat的工具代码,可以直接食用


 

 

  • 2
    点赞
  • 68
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值