Monday, November 8, 2010

Some Considerations on Asterisk for Receiving DTMF

Telephone dialpad


DTMF (Dual tone multi frequencies) are the tones which are generated when you press a digit, star or pound key on your phone’s dialpad. As our interaction with IVRs is increasing everyday, the use of DTMFs is obviously increasing with it. Whenever you call your bank, work place, a government office, voicemail, or almost anywhere, you have to go through a series of IVR options by pressing various digits, star and pound keys, or a combination of these.


So when setting up an asterisk server, it is very important that you correctly setup its DTMF detection mechanism.


In order to correctly setup DTMF,  first it is important to know that there are two types of DTMF: inband and out-of-band.


Inband are the DTMF tones which are just audio signals. When you press a digit on your dialpad, the tone you hear is exactly as it should be heard by the telephone system on the other end to do something useful. The problem with the inband DTMF is that telephone systems can also take high pitch sounds as some random DTMF digit. It happens in real life that a woman talking on the phone suddenly hears a DTMF digit send to the phone system when she had not pressed any digit. Women’s voices have higher pitch so they can more easily be incorrectly recognized as a DTMF digit than a male voice. Another drawback of inband DTMF is that if line is bad and call’s voice is not clear, DTMF won’t be sent correctly and the other end will not be able to correctly understand it. A noisy background can also cause the same effect. Using any codec other than g711/ulaw/alaw will also generally result the DTMF audio getting distorted.


Out-of-band DTMF on the other hand doesn’t have these problems. It is not an audio signal, it is a true digital signal and doesn’t get distorted by the scenarios mentioned above. But it requires that the sending party, i.e. the telephone has the capability so send out-of-band DTMFs. Unfortunately the phones, including the cell phones are all anlaog and they can’t send out of band DTMF.


Out-of-band is a reliable way of sending DTMF and it further supports two options: SIP-INFO and RFC2833. SIP-INFO is not much used and RFC2833 has become a standard way of using out-of-band DTMF over VoIP when using SIP.


Scenario 1


When setting up an Asterisk system which is dealing purely with the VoIP systems, you don’t have to worry about the VoIP part of it, and you really can’t do much about callers calling from non VoIP sources. All the IP phones have inband and out-of-band DTMF options. By default mostly they are already set to RFC2833. You don’t need to change it, but do verify that they are not set to something else.


On the Asterisk side, doesn’t matter which version you use, it’ll happily accept the DTMF tones without any extra configuration change.


Scenario 2


If there are both analog and VoIP phones attached to an Asterisk system, then you may need to tweak zapata.conf file. This is because zapata.conf is the file which takes care of the configuration of the physical hardware which enables your non VoIP phones to connect to the Asterisk server. If asterisk is receiving DTMF fine from the IP phones it doesn’t mean it should receive them fine from analog phones too. Tweaking zapata.conf includes not much other than to adjust rxgain and relaxdtmf values. Here rxgain=0.0 by default can be changed and relaxdtmf=no can be set to relaxdtmf=yes. But again, if your DTMF digits are coming in clear, due to bad connection, Asterisk will certainly hard time to understand them, and it may not recognize them at all.


Scenario 3


For any of the above scenarios, if a caller is calling from a source which is analog, i.e. a regular landline phone or a cell phone, then it’ll mean the incoming DTMFs are only analog and you can’t do much about them. If the user is calling from a cell phone, which transmit DTMF as audio signals, your asterisk server may not be able to listen to it clearly by the time it’ll hit it. You never know what paths this DTMF has gone through and how much has it got distorted by the time it has reached the asterisk server.

No comments:

Post a Comment