Introduction to Treating Echo in Telephony Systems and in Asterisk
Echo in telephony systems is a phenomenon in which one caller hears the echo of his own voice after a short (or long) delay, alongside the remote party's voice. There are two sources of echo in telephony systems:
- Network echo, which is produced by the interface between the two-wire local subscriber loop (a telephone set, for example) and the four-wire transmission system of telecommunications trunk lines (PBXs, PSTN, etc.).
- Acoustic echo, which is caused by feedback at the terminal device level, such as phone speaker acoustic feedback to its microphone.
Both types of echo can occur simultaneously in any single connection, compounding the negative effects. Although echo can be generated on both sides of the line (as a matter of fact, at each point that the four-wire system interfaces with the two-wire system), the echo that degrades phone call quality is typically generated on the other party's equipment (the remote side).
The reason that the local echo does not affect the call is simple: when a portion of the voice energy is fed back into the earpiece with a very small delay (milliseconds), we hear it as the positive feedback of a working telephone line. Telephone sets are designed to feed our voice back from the microphone to the earpiece, and the local echo is just additional volume that is perceived as acceptable.
Reducing Echo in Asterisk Systems
The main reason for line echo generation is impedance mismatch. Impedance is the circuit resistance to AC signals, and it changes with frequency. The first step to reduce echo is to match impedances.
In Asterisk, this is done in two steps:
- Set the country (in /etc/zaptel.conf loadzone = [your country]) and adjust the impedance of the FXO ports to match those of the PSTN lines.
- Fine-tune the impedance matching by running the “FXO Tune” program (execute the “fxotune” command as root user).
This program sends a tone to the telephone line and listens to the echo level. It checks the echo with different parameters, and chooses the parameter set that produces the least amount of echo.
Eliminating Echo in Asterisk Systems
The procedure described above will decrease the echo, but will not eliminate it. Echo cancellation is done by a signal processing code that compares the digital voice that is sent to the circuit with the digital voice that is received by the circuit. When a pattern is identified, the signal processing program subtracts it from the outgoing signal, producing an echo-free signal for transmission.