# Trivial echo separation

Say we have a signal S, and we composite it with a 0.1-volume 30-sample-delayed version of itself, so:

T(k) = S(k) + 0.1*S(k-30)


How would one rearrange this equation to make S the subject?

i.e given the resultant signal T, and the fact that we know the parameters of the echo (0.1 and 30), how to reproduce the original S?

The way the signal $T(k)$ is generated is by applying an FIR (finite impulse response) filter to the signal $S(k)$. The transfer function of this FIR filter is

$$H(z)=1+0.1z^{-30}$$

If you want to compensate for such a filter, you need a filter with a transfer function which is the inverse of $H(z)$:

$$G(z)=1/H(z)=\frac{1}{1+0.1z^{-30}}$$

This is a recursive filter with an infinitely long impulse response (IIR). If you filter the signal $T(k)$ with this IIR filter, the result will be $S(k)$.

To complement Matt L. perfectly correct answer, the easy way to rearrange your equation to solve for $S$ is just like you'd do for any simple arithmetic equation:

\begin{aligned} T_k &= S_k + 0.1 \; S_{k-30} \\ \iff \quad S_k &= T_k - 0.1 \; S_{k-30} \\ \end{aligned}

But, I hear you saying, there's still an $S$ on the right hand side! Yes, there is, but it's a delayed version of $S$. If you just start at, say, sample $0$ and compute $S$ for successive samples, then by the time you need to compute $S_k$, you already know $S_{k-30}$, because you just computed it 30 steps ago.

Of course, you still have a problem for the first 30 steps, since for those the equation ends up referring to a sample with a negative index. Indeed, you can choose any values you want for those negative-index samples, and still produce a valid output that satisfies the equations.

For practical purposes, you can just define those samples to be all zero, or perhaps equal to the mean of the first few actual samples. Fortunately, due to the $0.1$ decay factor in your equation, the influence of whatever values you choose to assign to those initial samples will fade away pretty rapidly, and should be imperceptible after only a few hundred steps.