信号处理(五)Echo cancellation and Estimating the distance 回声消除和距离估计

Connect your headphones to the sound card output of your PC and listen to this signal. You must correct the echo that is present on the signal. For this you will need to analyze the autocorrelation function of the signal. You can calculate it through - the Inverse Fourier Transform of the PSD of the signal (PSD given by the square of the modulus of the signal FFT), - the use the Matlab function xcorr.

Then you need to build a theoretical model for the signal (It’s up to you to propose a model):

x(n) = …

You deduce what should be the theoretical autocorrelation function of the signal. By then analyzing the measured autocorrelation function, you can identify the parameters of the echo signal and try correcting it.

X (t) is a random process, a (t) = EX (t) is the expectation, then the relevant function is defined as: B (s, t) = E (X (s) -a (t)) (X (t) -a (t)). If X (t) = Y (t) + i * Z (t), Y and Z are real processes, then X (t) is called a complex random process, and the relevant function is defined as: B (s, t) = E ( X (s) -a (t)) (X (t) -a (t)) (the latter bracket takes the conjugate).

1.Signal Acquisition

[x, fs] = audioread ('Pa11.wav');% Read signal
figure (1);% new window
subplot (3,1,1);% 3 row and 1 column arrangement
plot (x (1: 4000));% draw the signal
title ('Original signal');% Drawing area title
y = fft (x);% do FFT (fast discrete Fourier transform)
subplot (3,1,2);% 3 rows and 1 column arrange the second plot
plot (abs (y));% draw abs (y)
title ('Amplitude');% Drawing area title
subplot (3,1,3)% 3 rows and 1 column arrange the third plot
plot (angle (y));% Draw angle (y)
title ('Phase');% Drawing area title
Sound (x, fs);% matrix converted into sound signal

在这里插入图片描述

2.Echo cancellation

b = 1;
a = zeros (1,1800);
a (1) = 1;
a (601) = 0.7;
a (1001) = 0.4;
z1 = filter (b, a, y);
z2 = fft (z1,4000);
figure (3);
subplot (3,1,1);% 3 rows and 1 column arrange the first graph
plot (abs (z2));% draw abs (z2)
title ('Filtering amplitude');% Drawing area title
subplot (3,1,2);% 3 rows and 1 column arrange the second plot
plot (angle (z2));% draw angle (z2)
title ('Filter phase');% Drawing area title
subplot (3,1,3);% 3 rows and 1 column arrange the third plot
plot (z1 (1: 1024));% draw z1
title ('Filtered signal');% Drawing area title

在这里插入图片描述

3.Estimating the distance of reflectors from sound signals with echoes

h = xcorr (y);
figure (4);% Create a figure window
subplot (4,1,1)% 4 row 1 column first graph
plot (abs (h));% draw abs (h)
title ('Most value');% Drawing area title
h1 = h (5600: 6000);% h1 matrix
[r1, t1] = max (h1');% max
t1 = t1 + 5600;
subplot (4,1,2);% 4 row 1 column 2nd plot
plot (h1)% draw h1
title ('point 1');% Drawing area title
h2 = h (6200: 6600);% h2 matrix
[r2, t2] = max (h2);% max
t2 = t2 + 6200-t1;
subplot (4,1,3);% 4 row 1 column 3rd plot
plot (h2);% draw h3
title ('point 2');% drawing area title
h3 = h (6800: 7200);% h3 matrix
[r3, t3] = max (h3);% max
t3 = t3 + 6800-t1;
subplot (4,1,4);% 4 row 1 column 4th plot
plot (h3);% draw h3
title ('point 3');% drawing area title
t=[t1,t2,t3];

在这里插入图片描述
t1=5801 t2=600 t3=1000

If we get the number of delay sampling points as n, then we can use t = n / fs to calculate the delay time, and then use L = v * t to calculate the distance, that is, L = v * n / fs, Finally, the distance between the reflector and the sound source can be determined according to the relative positions of the reflector, sound source, and receiver in practice.
The audio signal selected for this design is fs = 22050Hz, so the distance between the sound source and the two reflectors is:

   L1 = 340 * 5801/22050/2 = 44.72m
   L2 = 340 * 600/22050/2 = 4.63m
   L3 = 340 * 1000/22050/2 = 7.71m
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值