How do I use software-based echo cancellation?

Echo echo echo echo…

but not that bad :slight_smile:

I have an echo off of my trunk calls.

My trunks are DAHDI and my phones are all analog.

I use a TDM2400P. In the user manual it says…

“The 2400 Series cards, unless otherwise equipped, utilize Asterisk to
perform software-based echo cancellation.”

Great. Does anyone know how?

I run the FreePBX Disto V.1.813.210.58 (latest stable release to date).

Thanks!

Digium DAHDI documentation:

http://docs.tzafrir.org.il/dahdi-linux/

http://kb.digium.com/articles/Troubleshooting/General-Echo-HOWTO

Also various 3rd party echo cancelers are available

Far out! Thanks!

Groovy <>

Did you manage to cancel the echo with DAHDI ?

It is important to do fxotune to get the best possible balance, once you have done that the software canceller works fine.

You should only use cards with Hardware Echo Cancellation. Why anyone would buy a card without it is just crazy. Software echo can never seems to work 100% and I hate the constant training it has to do.

I agree but some of us are stuck with what we have.

The new generation of software echo cancellation are (1) significantly improved from the old generation (2) can handle complex scenarios that hardware echo cancellation fails to handle (3) provides greater flexibility to the system administrator and (4) the training is no longer required. As I see it, their only disadvantage is that they consume portion of your main CPU.

Therefore, if you are designing a new system don’t automatically select the legacy way of using hardware echo cancellation.

I hope someone can point me in the right direction with this one…

I type in: fxotune -i -n 4 -b 1 -e 24 -p -vvv
I get a response of:

/dev/dahdi/1 absent: Device or resource busy
/dev/dahdi/2 absent: Device or resource busy
/dev/dahdi/3 absent: Device or resource busy
/dev/dahdi/4 absent: Device or resource busy
/dev/dahdi/5 absent: Device or resource busy
Tuning module /dev/dahdi/6
Unable to set impedance on fd 4
Failure!
Tuning module /dev/dahdi/7
Unable to set impedance on fd 4
Failure!
/dev/dahdi/8 absent: Device or resource busy
/dev/dahdi/9 absent: Device or resource busy
/dev/dahdi/10 absent: Device or resource busy
/dev/dahdi/11 absent: Device or resource busy
/dev/dahdi/12 absent: Device or resource busy
/dev/dahdi/13 absent: No such device or address
/dev/dahdi/14 absent: No such device or address
/dev/dahdi/15 absent: No such device or address
/dev/dahdi/16 absent: No such device or address
/dev/dahdi/17 absent: No such device or address
/dev/dahdi/18 absent: No such device or address
/dev/dahdi/19 absent: No such device or address
/dev/dahdi/20 absent: No such device or address
/dev/dahdi/21 absent: Device or resource busy
/dev/dahdi/22 absent: Device or resource busy
/dev/dahdi/23 absent: Device or resource busy
/dev/dahdi/24 absent: Device or resource busy
Unable to tune 2 devices, even though those devices are present

There is nothing on ports 6 & 7 so I think that part makes sense. Ports 21-24 are trunks.

I don’t know. Any ideas why I get this response?

Thanks!

Any reason you are trying to tune non-fxo ports?

Just tune the fxo ports.

You have to stop Asterisk before you proceed.

One of the few time to use service asterisk stop

Restart when done with amportal start

Don’t just type commands, look up what they do and adjust for your circumstances.

If 21-24 are your telco ports then set them as the start and end points.

below is the man page:


NAME 
fxotune − automatically tune DAHDI FXO channels

SYNOPSIS 
fxotune −i [options] − detect mode

fxotune −d [ options ] − dump mode

fxotune −s − Startup mode

DESCRIPTION 
fxotune is a script that fine-tune parameters of the FXO modules of the card. It has three modes of operation:

Detect mode (−i): it detects and tunes all the available FXO channels. It writes settings to a configuration file (/etc/fxotune.conf) from which it can be loaded (e.g: at startup) using −s .

Dump mode (−d): Runs detection on a single DAHDI channel, and just dumps waveforms to fxotune_dump.vals is generated in the current directory.

Startup mode (−s): fxotune just reads the settings from fxotune.conf into the FXO modules.

You are advised to run fxotune on all FXO ports you have that support it and that are connected. Note that the tunning is affected by e.g. the physical parameters of the connection, and thus if it has been radically changed, you may need to re-run fxotune.

This program only works for the Digium TDM400P/800P/2400P cards and compatible and the Xorcom Astribank devices. Other cards (notably X100P cards and clones) do not have the hardware to support such tuning.

The tuning process needs a clear line to do the tuning. In order to do that, it runs in cycles of the following: sets the line off-hook, dials a dial string (which should set the PSTN provider waiting for the next digit), and then starts tuning. It has a limited ammount of time for tuning before the PSTN gives up and gives a busy tone. So after a while it hangs up and starts a new cycle.

fxotune has two operation modes: tune (−i) and set (−s). In the tune mode it generates /etc/fxotune.conf, and in the set mode it merely applies the parameters from fxotune.conf to device’s ports.

OPTIONS 
The following options below except −v (verbose) affect only the detection process and hence apply only to the detect and dump modes.

In addition, to maintain compatibility with older versions of fxotune, if in detect or dump mode there is a parameter with option before it, it is considered to be the dialstring parameter (−n).

−b startdev

Start tuning from dahdi channel num. startdev: skip all previous channels. By default starting from channel 1.

In dump mode (−d) this is the single channel that will be tested.

−e stopdev

Tune only up to dahdi channel num. stopdev: skip all previous channels. By default stopping at channel 252.

In dump mode (−d) this parameter is ignored.

−l delay-to-silence

Time in seconds to wait after dialing the dial-string to get a clear line. The default is 0. before

−m silence-good-for

Time in seconds which states how long the PSTN will wait after we dialed the dial-string until it starts giving a busy tone. You can test this by connecting an analog phone to the line and dialing.

The default is 18 (18 seconds).

−n dial-string

Digits to dial to the PSTN in order to get it stop its dialtone and waiting for the next digit.

The default is "4" (sending just the digit 4). It should work in most cases. Again, this can be tested by connecting a phone to the PSTN line and dialing the dial-string.

−t detect-type

This option allows using the older detection method used by fxotune of Zaptel 1.2. use −t 1 for that older method. whereas −t 2 (the default) uses the current method.

This option only applies to detect mode (−i).

−v[vvvv]

Sets debugging on. The more v-s, the higher debug level.

Note that: −vv −v will actually set debug level to 1 instead of 3.

−w wave-form

The default: −1, for multitone waveform. Alternatively: a frequency of a single tone.

This option only applies to dump mode (−d).

EXAMPLES 
fxotune −i 9

if you need to dial 9 for an external line. If you always get a line, you can simply use any digit.

−s

Load settings from the last test. Used at startup.

FILES 
/etc/fxotune.conf

The configuration file generated by fxotune in detect mode and from which configuration is loaded when −s is used.

NOTES 
Running fxotune takes approximately a minute per port. If you wish to only run fxotune for several ports, you can use the options −b and −e to set a specific range of ports. Another useful trick is to actually keep asterisk running, and only "destroy" the dahdi channels you wish to tune (dahdi destroy channel NNN): other channels will be used by Asterisk, and hence skipped. This can be useful if you have many FXO ports that are not connected.

fxotune writes immediately to /etc/fxotune.conf so if you stop it half-way, you may get a half-configured system. If you have already tuned your FXO channels and wish to test-run fxotune again, you are advised to backup /etc/fxotune.conf .

The default for −m is 18 seconds. This asusmes that you get a clear line for at least 18 seconds. It is advised that you test that timeout earlier by connecting a phone to the FXO line, dialing 4 (or whatever dial string you put with −n) and see how much time of silence you have.

If you connect your device to a PSTN provider that is not in the US, there is a similar operation you should apply before even getting to fxotune: setting the opermode. The opermode sets a number of country-specific parameters. For the Digium analog cards this is set through the kernel module parameter ’opermode’ . For the Xorcom Astribank this is set through the variable ’opermode’ in /etc/dahdi/xpp.conf . For valid values of this parameter, see /usr/share/asterisk/init_fxo_modes (FIXME: this has changed and will change. Tzafrir).

SEE ALSO 
dahdi_cfg(8), dahdi_tool(8), dahdi_monitor(8), asterisk(8).

I do read, I swear. Sometimes it’s another language to me. I’m learning but it’s a curve and a half. Of course, if I read and understood, I don’t think I would be here. Thanks for your help. I saw nothing on needing to stop the Asterisk server.

2 Questions:

  1. You are saying I only need to tune the FXO ports? I realize the FXOtune is for FXO. What about internal lines (extension to extension calls)? The originator gets an echo. The receiver does not get an echo but the originator does.

  2. So, I shut down asterisk, run fxotune -i -n 4 -b 21 -e 24 -p -vvv, and the rest is configured by itself (assuming none of the top five detected echo cancellation parameters do not have coefficients of all zeros)?

Shandley - A point to consider, instead of beating your head against a wall why not hire a professional and get this set up right?

FreePBX is free to use that does not make it easier to learn than a 100k Cisco Call Manager platform.

To add to the confusion you are using analog phones with a digital system, this adds an entire additional level of complexity.

30 years ago when we were putting channel banks on digital switches to serve analog lines. The levels were set in .5 dbm intervals (and it may not be millivolts it might be a reference to .775 volts at 600 ohms, remember that db is not a unit of reference but a logarithmic expression of energy) and called “prescription” levels. The precise setting of levels is why your land line sounded so good. The cables were measured for loop loss and the levels matched to make sure that impedance mismatches did not occur. Mechanical echo like you are experiencing is a function of impedance mismatches.

Remember the first time you rebuilt an engine and you put the distributor in 180 degrees out? The boom and carb fire was a great educator to not do that again (please excuse this reference if you are one of those men who happens to have a vagina and can’t change his own oil). Every good phone guy has gotten the levels wrong and heard what a really f(***'d up line sounds like. To the unitiated it sounds like it will never work. Like the distributor analogy golden audio is just a screwdriver turn away.

In this case they don’t equip analog cards with level controls (pity as it is the most efficient way to accomplish the task) so you have to set the levels in the configuration.

FXO tune is not performing god like functions, it is merely sending some tones and roughly setting the levels on the lines. Usually it is good enough that it becomes within the range of the ability of the software echo cancellation facility. However it particularly nasty situations you still have to tweak the results.

Since station ports can’t loop audio back the process can’t be automated. You must have really bad cable or particularly crappy phones (or a combination of the above). We already know you are cheap as you would rather endure all this pain than purchase digital phone sets.

So you need to set the levels, sounds simple but I went through all of this for two reasons. 1) I like to hear myself talk 2) Because it illustrates my original point.

I can no more teach you how to finesse the levels on the trunks than a brain surgeon could talk me through a patching up a blown vessel. It just ain’t gonna happen. You can spend hours farting around with it or you can spend a couple of bucks putting up with an arrogant pr**ck like me and have it taken care.

If this sounds like something you want to do just click the support link above. I won’t be insulted if you ask for anyone other than me.

Ha! I love it. I will always fall on paid support if it is something I simply cannot do; however, the entire point of this box was to learn the system as much as I can. We had a few dollars extra in the year-end fund and we wanted to make the phone system something we could change around if we needed. I’ve spent 30-40 hours on this system at work and double that on my own time adding features I would like to see (softphones are fantastic!). I’ve learned plenty. I will continue to trial and error just for the sake of learning. I make well documented backups of everything in case something fatal happens.

I have an electrical background (so I get the line loss talk) but I have a very strong passion for computer related anything, including the conversion of analog to digital. I just so happen to work in an office where the telephone system is just that.

What’s weird is… after all of that time, I don’t know the basic commands. I just today found out how to bring up the commands in Asterisk. Sometimes, the easy stuff is a post away. Sometimes, the hard stuff is a post and a half away. More-so, I like the idea that if I have had the problem, someone else my stumble on the back and forth that you get with a forum like this. Banging my head against a wall will induce a lesson… eventually. :slight_smile:

My favourite part of your post was the distributor analogy. I’ve been there, done that.

If I do pay for support, I would like you to be that one. You’ve helped me (even in the days of fonality trixbox forum) and I look forward tot he day when I need your deluxe service.

I am glad you took it with good humor. Someone else could have seen it as a flame. I was just having some fun.

Start reducing the rx gain in 3db increments on the fxs side and see if that helps.

This old trixbox post is still relevant: http://fonality.com/trixbox/forums/community-edition/help/independent-dahdi-channel-rx-tx-gain-volume

Remember when in Asterisk 99% of the commands are diagnostic so poke around all you want. The ‘?’ is your friend. Want to know the sip commands do a sip ?

A simple ? at the top will show all the commands, it is very useful.

Make sure that you turn off the debug (core set verbose 0) or the crap will be scrolling across the screen.