Echo Cancellation Issues

Introduction

One of the dirty truths about Asterisk is that if you do not configure your Zaptel hardware correctly, you will at one time or another experience serious echo issues with connecting VoIP lines to the PSTN. Thankfully, Asterisk has some pretty useful methods for taking care of echo.


			#KFLAGS+=-DECHO_CAN_STEVE
			#KFLAGS+=-DECHO_CAN_STEVE2
			#KFLAGS+=-DECHO_CAN_MARK
			KFLAGS+=-DECHO_CAN_MARK2
			#KFLAGS+=-DECHO_CAN_MARK3
		

Figure 1. Zaptel Makefile compile options

In Figure 7-1, you can see there are several options for echo cancellation. Commenting out all but one of these lines is required. If you'd like to use the MARK3 echo canceler, for instance, you'd comment out the MARK2 line and uncomment the MARK3 line.

All four of the echo cancelers will do a mediocre to good job of taking care of echo, but it takes a little while for Asterisk to properly adjust. If you use the MARK2 canceler, there's an additional option:


			#KFLAGS+=-DAGGRESSIVE_SUPPRESSOR
		

That can be added for additional echo cancellation. Aggressive suppression works well, but can make the conversation sound scratchy in the beginning.

Echo Training

Now, thanks to the efforts of Brian West and the other Asterisk gang, we now have a feature in Zaptel called Echo Training. Echo training, in my experience, works the best out of all of the echo cancelers.


			[channels]
			echocancel=yes
			echocancelwhenbridged=yes
			echotraining=yes
			rxgain=8.2
			txgain=1.0
			signalling=fxs_ks
			channel=1
			

Figure 2. zapata.conf echo training definition for FXO channel

Echo training is enabled with two separate sets of settings - first of all, make sure you have echocancel=yes, echocancelwhenbridged=yes, and echotraining=yes. These are the first steps to effective cancellation. There is another important setup consideration that you should follow: properly adjusting your rxgain/txgain.

Adjusting the rxgain/txgain Settings

In order to adjust txgain/rxgain properly, you need to use the ztmonitor application to check the power of your audio signal as a call is in progress. The steps for tuning rxgain/txgain are as follows:

  1. Set default values of rxgain/txgain to 1.0

  2. Initiate a call that flows out of your Zapata device.

  3. Look at the ztmonitor visualization (explained below) to see whether the audio is in optimal condition.

  4. If it is not optimal, increase or decrease the txgain/rxgain levels accordingly.

Most people find that they need an rxgain level around 8.0 to have good echo cancellation. The txgain setting varies from installation to installation.


				astpbx1:/usr/src/pbx/zaptel# ./ztmonitor 1 -v
				Rx############                 Tx#####################
			

Figure 3. ztmonitor output

In the above output, we see a text-based VU meter showing the relative power of the audio source. The Rx channel is right where we want it, so the rxgain setting you have in your configuration is good. The Tx level, however, is pegged all the way to the end of the screen (use your imagination), in which case the audio is doing something called "over deviation" - it's the same thing that happens when people get too close to a microphone and the audio is crackly. When this occurs, the echo canceler cannot compensate for the signal as well since it is busy receiving artifacts of the audio that "spill" back into the channel. In this case, we want to lower the txgain level a bit.

Most people who configure echo training correctly will never hear echo in their calls again. The echo canceler works nearly instantaneously in echo training mode.