> BTW, can someone explain to a libart major like me (;-)) where echo
> comes on in a telephone conversation? I seem to recall it's due to the
> length of the line between the CO and the local party, but I'm not
> sure.
I'll try.
Echo occurs when part of the signal traveling in one direction
on the phone line, is reflected back in the opposite direction.
It's similar (in effect) to the echo you hear when you speak in
a large room, and your voice reflects from a wall... but it's
occurring in the electrical domain rather than in the air-pressure
domain. It's also similar to the way in which radar detects the
presence of an airplane, by bouncing a high-frequency radio signal
off of the plane.
A signal reflection can occur whenever a signal, which is traveling
through a transmission medium (air, wires, etc.) encounters an
impedance change. In the case of a spoken echo, the impedance
change is between the air (whose molecules move fairly easily
in response to sound pressure) and the wall (whose molecules are
bound together, and thus form a "stiff" material). In the case
of radar, it occurs when the radio pulse tries to move from
free space, into the metal surface of the plane.
In the case of a phone connection, the echo occurs when the
incoming electrical signal (e.g. from the CO) reaches the end
of the phone wire (which has a certain characteristic impedance)
and tries to move into the receiver circuitry (the telephone,
or the line card in an Asterisk system).
In each of these cases, if there's a difference in impedance
between the transmission medium, and the "termination" (whatever
is at the end of the medium), only a portion of the incoming signal
flows into the termination. The other portion of it is reflected
back towards its origin - an echo of one sort or another. In the
case of an Asterisk line card with a mismatched impedance, the
person calling into the Asterisk system will hear a significant
echo ("far-end echo" from their point of view). The spacing of
the echo (between the time they speak, and the time they hear
themselves in the echo) will depend on the length of the
phone path between you and them... signals in the phone line
travel at less than the speed of light. Far-end delay over
satellite phone links can be very obvious!
Echo can also occur in the other direction... the audio signal
being sent out by the Asterisk system can reflect right back
into the card (partially, at least) the moment it hits the
different impedance in the phone line - a "near-end echo".
Eliminating the echo can be done in a couple of ways. The
most thorough way is to exactly match the impedances
involved (e.g. match the line card to the line impedance) so
that there is no tendency to reflect. If that's not possible,
it's possible to analyze the echo behavior and use DSP to cancel
it out... e.g. you can prevent your system from generating a
far-end echo that the other guy hears, by sampling his incoming
audio signal (what you receive), and deliberately retransmit a
small amount of it... just enough (and with the right phasing
relationship) to cancel out the portion of his signal which is
reflecting off of your line card's impedance discontinuity.
> Is there a way to keep track of this issue, and overtime, to configure
> it to answer a call by expecting such and such echo, and thus, avoid
> starting sampling from scratch every time?
To some extent, yes, I believe it's possible at least in part. If
you can measure the extent and character of the near-end echo being
created in signals you transmit, you can calculate the nature of
the impedance discontinuity and figure out what you need to transmit
to compensate for it, and thus prevent the generation of echo. If the
line characteristics change, though, you may have to start over again,
or adapt your current behavior.
Canceling out far-end echo (from anything beyond your own CO)
is a different matter, because it's likely to be different on
every call you make.