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