Echo cancelling using autocorrelation function I was given a problem, but I couldn't solve. I did some researches but I still didn't figure it out. Here is the problem:

An audio signal $ s(t) $ is generated by a speaker reflects in a wall with reflection coefficient $ \mu (\mu &lt; 1) $. The signal $ x(t) $ is recorded by a microphone close to the speaker and far from the wall, after sampled, is given by:

$ x(t) = s(t) + \mu s(t - k) $

Where $ k $ is the delay given in samples due to the echo.

So, my goal here is to estimate $ \mu $ and $ k $, observing the autocorrelation function of $ x(t) $, $ r_{xx}(l) $, that can be writen in function of the autocorrelation function of $ s(t) $, $ r_{ss}(l) $. I was able to compute this autocorrelation function and I got:

$ r_{xx}(l) = (1 + \mu^{2})r_{ss}(l) + \mu r_{ss}(l-k) + \mu r_{ss}(l+k) $

So, it obvious has three peaks: when $ l = 0 $, when $ l = k $ and when $ l = -k $.

Assuming that $ r_{ss}(l) = 0 $ for $ |l| &gt; k/10 $, I think that I can obtain the value of k observing the side peaks, and the value of $ \mu $ observing the central peak, but i wasn't able to formalize it mathematically. Could anyone help me to do so?

Thanks in advance.
Haven't you already got it there?

$$
\hat{k} = \arg \max_{l &gt; \frac{k}{10}} r_{xx}(l)
$$
and
$$
\hat{\mu} = \sqrt{\frac{r_{xx}(0) }{ r_{ss}(0) } - 1}
$$

The R code below outputs the figure and:


  "k Estimate: 613  vs  613  mu Estimate :  0.747619585689531  vs  0.768768"






R Code

# 26617

T &lt;- 10000
mu &lt;- 0.768768
k &lt;- 613

s &lt;- filter(runif(T,-1,1), rep(10/k,k/10), circular = TRUE)


x &lt;- s + mu*c(rep(0,k),s[1:(T-k)])


par(mfrow=c(2,1))
r_xx = acf(x, lag.max=1000, type="covariance")

min_idx &lt;- floor(k/10)
mx &lt;- which.max(r_xx$acf[(min_idx+1):10000])

khat &lt;- min_idx+mx-1 # R indices start from 1, not 0

points(min_idx+mx,r_xx$acf[khat], col="red", pch=19)

r_ss = acf(s, lag.max=1000, type="covariance")

muhat &lt;- sqrt( r_xx$acf[1] / r_ss$acf[1] - 1 )
print(paste("k Estimate:" , khat, " vs " , k, " mu Estimate : ", muhat, " vs ", mu ))