利用 dahdi_monitor 来捕获进入线路上的音频信号

来源:互联网 发布:热血江湖武勋阶段数据 编辑:程序博客网 时间:2024/05/23 23:15

原文在这  http://wiki.ljackson.us/Asterisk_Echo  直接看这个可能还方便些

Visually Monitor a Zaptel channel:监视一个通道

[root@asterisk ~]# dahdi_monitor<channel num> -v

Record a Zaptel channel 记录/录制一个通道

[root@asterisk ~]# dahdi_monitor<channel num> -f <filename.raw>


Convert the raw file to a wav file for review. 转换成wav格式的文件
sox -r 8000 -s -w -c 1 <filename.raw> <filename.wav>

eMail the recording to yourself:以附件的形式发送邮件

uuencode <filename.wav> <filename.wav> | mail -s <filename.wav> <email@server.ext>

Next we need to make sure our echo settings, these settings are in /etc/asterisk/zapata.conf

The settings we will be looking at are listed below with typical default settings.

echocancel=yes

echocancelwhenbridged=no

echotraining=800

rxgain=0.0

txgain=0.0

Let's take a look at what these settings actually do.

echocancelObviously this disables or enables echo cancellation, it is recommendedto not turn this off. The yes setting sets the value to 128, this isthe number of taps that are used. Each tap is one sample from the datastream. You can specify the number of taps to use as 16, 32, 64, 128,or 256. It is very rare that you need anything other than setting thisto the yes setting.

echocancelwhenbridgedThis enabled or disabled echo cancellation when TDM calls are bridged.TDM calls should not need any echo cancellation but some people reportimproved call quality with this option turned on.

echotrainingA common echo symptom is that at the beginning of a conversation thereis a good deal of echo and then it fades away as it it trains itself.If this delay is too long, you can adjust the training cycle. Thesetting is represented as milliseconds and can accept any value between10 to 4000. Making the setting to low will not enable the system totrain properly. I find that setting this to 128 is often a goodstarting point.

rxgainThis adjust the gain of the inbound signal. While Asterisk will acceptany number from -100 to 100 (-100% to 100% of capacity) it isrecommended to never put the values to more than -11 to +11 and in somecase anything outside of the -5 to +5 range will actually cause audioloss (mostly on the TDM400 cards).

txgainThis adjusts the audio gain for the signal being sent out to the phoneline. While Asterisk will accept any number from -100 to 100 (-100% to100% of capacity) it is recommended to never put the values to morethan -11 to +11 and in some case anything outside of the -5 to +5 rangewill actually cause audio loss (mostly on the TDM400 cards).

One of the first questions commonly asked is "what is the bestsettings for the rxgain/txgain?" and simply put, there is no "bestsettings" that will work for everyone. Every installation is differentas there is no perfect consistency between telephone line quality,impendence, line length, etc. So how do you know what settings to useto make the system work properly? Well, the zaptel developers havecreated some handy tools to help us with that. The primary tool we willuse is ztmonitor This tool allows us to visually see the audio levelson the RX and TX sides allowing us a guide to adjusting the levels inthe zapata.conf file.

The command format is:

ztmonitor <zap channel> -v
An example of monitoring zap channel 3 during a conversation is shown here:
[root@asterisk1 ~]# ztmonitor 3 -v

Visual Audio Levels

Use zapata.conf file to adjust the gains if needed.

( # = Audio Level * = Max Audio Hit )

<-------------(RX)-------------> <-------------(TX)------------->

################ * ######################### *

If those were the maximum levels that we were seeing during a call,we would know that the RX gain is set pretty good but the TX level isway too high. What we are looking for are peaks that don't go past themiddle of the meter.

Although this may sound complicated, it is fairly simple toadjust these settings on the fly. My prefered way is to use an SSHclient such as Putty to have three sessions open at the same time. Onewindow will have the Asterisk CLI, the second will be runningztmonitor, and the third will have zapata.conf file open in an editor.During the call, if you need to adjust a setting, make the change tothe file and save it, then switch to the Asterisk CLI and type thefollowing:

asterisk1*CLI> reload chan_zap.so

This will reload the zap module without hanging up the call. Whenyou have made you adjustment, stop and restart Asterisk just to makesure you have the right settings. With a little practice you should beable to do these basic echo adjustments in just a few minutes.

Again, this will not solve every echo problem, but for themajority of installations we have done, this was all we needed to do tovirtually eliminate the echo problems from the TDM and TE connections.