dahdi_tools 分析 (七) fxotune

dahdi_tools 分析 (七) fxotune

fxotune

A utility for tuning the various settings on the fxo modules

一个用于调节 FXO (SI3050)参数(主要是阻抗)的工具。

usage

Usage: fxotune [-v[vv] (-s | -i <options> | -d <options>)

        -s : set previously calibrated echo settings
        -i : calibrate echo settings
                options : [<dialstring>] [-t <calibtype>]
                [-b <startdev>][-e <stopdev>]
                [-n <dialstring>][-l <delaytosilence>][-m <silencegoodfor>]
        -d : dump input and output waveforms to ./fxotune_dump.vals
                options : [-b <device>][-w <waveform>]
                   [-n <dialstring>][-l <delaytosilence>][-m <silencegoodfor>]
        -v : more output (-vv, -vvv also)
        -p : print the 5 best candidates for acim and coefficients settings
        -x : Perform sin/cos functions using table lookup
        -o <path> : Write the received raw 16-bit signed linear audio that is
                    used in processing to the file specified by <path>
        -c <config_file>

                <calibtype>      - type of calibration
                                   (default 2, old method 1)
                <startdev>
                <stopdev>        - defines a range of devices to test
                                   (default: 1-252)
                <dialstring>     - string to dial to clear the line
                                   (default 5)
                <delaytosilence> - seconds to wait for line to clear (default 0)
                <silencegoodfor> - seconds before line will no longer be clear
                                   (default 18)
                <device>         - the device to perform waveform dump on
                                   (default 1)
                <waveform>       - -1 for multitone waveform, or frequency of
                                   single tone (default -1)
                <config_file>    - Alternative file to set from / calibrate to.
                                   (Default: /etc/fxotune.conf)

用法举例

root@localhost:/fxs_test# ./fxotune -i -b 3 -e 3 -p 
Tuning module 3
Top 5 results for Acim2_tune Test
Res #1: index=1,  10,  0,  6,  1,254,  2,255,  0,  0: magnitude = 139, echo = -35.3670 dB
Res #2: index=66,  10,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 192, echo = -32.5711 dB
Res #3: index=32,   4,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 293, echo = -28.9154 dB
Res #4: index=71,  15,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 308, echo = -28.4814 dB
Res #5: index=64,   8,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 335, echo = -27.7510 dB
Done!
  • 自动调整阻抗成最佳匹配值。-p 显示前5最佳阻抗参数值。
  • 最佳参数值保存在 /etc/fxotune.conf
root@localhost:/fxs_test# cat /etc/fxotune.conf 
3=10,0,6,1,254,2,255,0,0

源码分析

核心函数是 acim_tune2

main
  -> do_calibrate
    -> acim_tune2

在这里插入图片描述

在这里插入图片描述

echo_trys 里面预定义了 72 组预设值

调用 iotcl WCTDM_SET_ECHOTUNE &echo_trys[trys] 依次设置

发送测试音频,并读取返回的音频数据,计算回声的大小。选出回声最小的参数值。

实测

# 设置 fxs 端阻抗值为 CHINA 200  + (680  || 100 nF)
# insmod mytdm opermode=CHINA fxshonormode=1  

root@localhost:/fxs_test# ./fxotune -i -b 3 -e 3 -p 
Tuning module 3
Top 5 results for Acim2_tune Test
Res #1: index=1,  10,  0,  6,  1,254,  2,255,  0,  0: magnitude = 139, echo = -35.3670 dB
Res #2: index=66,  10,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 192, echo = -32.5711 dB
Res #3: index=32,   4,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 293, echo = -28.9154 dB
Res #4: index=71,  15,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 308, echo = -28.4814 dB
Res #5: index=64,   8,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 335, echo = -27.7510 dB
Done!

当 fxs 端阻抗值为 CHINA , fxotune 得到 最佳 acim 值为 10 , 是对的!

在这里插入图片描述

# 设置 fxs 端阻抗值为默认值 FCC
# insmod mytdm 

root@localhost:/fxs_test# ./fxotune -i -b 3 -e 3 -p 
Tuning module 3
Top 5 results for Acim2_tune Test
Res #1: index=0,   0,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 81, echo = -40.0676 dB
Res #2: index=67,  11,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 195, echo = -32.4299 dB
Res #3: index=70,  14,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 419, echo = -25.7992 dB
Res #4: index=1,  10,  0,  6,  1,254,  2,255,  0,  0: magnitude = 473, echo = -24.7599 dB
Res #5: index=69,  13,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 698, echo = -21.3783 dB
Done!

当 fxs 端阻抗值为 FCC (600) , fxotune 得到 最佳 acim 值为 0, 是对的!

小结

fxotune 的作用是匹配最佳阻抗值,这可以使线路回声达到最小。

安装完CenterOS5.4 系统登陆后进到#号下,一般我们选择/usr/src目录进行下载及安装: cd /usr/src //安装开发环境及编绎环境: yum -y groupinstall 'Development Tools' yum -y install libtool* yum -y install kernel-heads* yum -y install ncurses-dev* yum -y install kernel-devel yum install -y kernel kernel-devel //下载最新的ver:1.6版本 wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4.10.2.tar.gz wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.2.8-rc1.tar.gz wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-1.6.2.1.tar.gz wget http://downloads.asterisk.org/pub/telephony/dahdi-linux/releases/dahdi-linux-2.3.0.tar.gz wget http://downloads.asterisk.org/pub/telephony/dahdi-tools/releases/dahdi-tools-2.3.0.tar.gz //安装libpri: tar zxvf libpri-1.4.10.2.tar.gz cd libpri-1.4.10.2 make make install cd .. //安装dahdi驱动: tar zxvf dahdi-linux-2.3.0.tar.gz cd dahdi-linux-2.3.0 make make install cd .. //安装dahdi-tools工具: tar zxvf dahdi-tools-2.3.0.tar.gz cd dahdi-tools-2.3.0 ./configure make make install make config cd .. Dahdi开启回音消除模块:编辑/etc/dahdi/modules 在末尾处添加Dahdi_echocan_mg2 yum install libxml2-devel ncurses-devel subversion doxygen texinfo yum install gcc-c++ make gnutls-devel kernel-devel //安装asterisk: tar zxvf asterisk-1.6.2.8-rc1.tar.gz cd asterisk-1.6.2.8-rc1 ./configure make make install make config make samples cd .. //安装asterisk扩展包(H323\mysql支持): tar zxvf asterisk-addons-1.6.2.1.tar.gz cd asterisk-addons-1.6.2.1 ./configure make make install make samples 至此 asterisk的基本环境安装完毕!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值