From FreeSWITCH Wiki
Jump to: navigation, search


Syntax of teletone scripts


0-9,a-d,*,# (standard DTMF tones)

variables: c,r,d,v,>,<,+,w,l,L,loop,%

  • c=x Sets the number of channels.
  • r=x Sets the sample rate.
  • d=x Sets the default tone duration.
  • v=x Sets the default volume (-63.0dB to 0.0dB).
  • >=x Number of ms per interval for volume decrease.
  • <=x Number of ms per interval for volume increase.
  • +=x Number of dB to step per interval (used by '<' and '>').
  • w=x Default silence after each tone.
  • l=x Number of times to repeat each tone in the script.
  • L=x Number of times to repeat the the whole script.
  • loops=x Like L, but doesn't pre-allocate a buffer for total duration, only one loop worth, then programmatically loops it (more mem efficient).
  • %=x A generic tone specified by a duration, a wait and a list of frequencies.

The values for '+' and 'v' may be decimal numbers.

Standard tones can have custom duration per use with the () modifier 7(1000, 500) to generate DTMF 7 for 1 second then pause .5 seconds.


ITU-T Recommendation Q.35 "Technical Characteristics of Tones for Telephone Service" defines many of these tones. They are provided here for your convenience, and because they make great examples. Additionally, RFC 2833 references ITU-T E.182 "Application of tones and recorded announcements in telephone services" for when to use certain tones in RTP. You may want to look at ITU-T Recommendation E.180 for different countries, what tones are used, etc.

UK Ring Tone [400+450 Hz on for 400ms off for 200ms then 400+450 Hz on for 400ms off for 2000ms]


US Ring Tone [440+480 Hz on for 2000ms off for 4000ms]


ITU E.182 Calling card service tone (AT&T BONG) [volume level -7DB, 941.0Hz +1477.0Hz (DTMF #) for 100ms with no wait. 350.0Hz+440.0Hz (US DIALTONE) for 1400ms with even decay of .1 dB over 2ms


Vacant Number Special Information Tone (SIT - The number you have dialed is not in service / disconnected) 913.8 Hz for 274 ms with no wait, 1370.6 Hz for 274 ms with no wait, 1776.7 Hz for 380ms with no wait


UK Special Information Tone (SIT - The number you have dialed is not in service) 950Hz for 330 ms with 15ms wait, 1400Hz for 330 ms with 15ms wait, 1800Hz for 330ms with 1s wait


ATTN TONE ("barking dog", means phone's off the hook!) 1400+2060+2450+2600 Hz for 100ms with 100ms wait


Caller Waiting Tone (aka SAS) 440Hz for 300ms repeated once after 10 seconds


Distinctive Ring/Call Waiting (indicates dialed number is greater than 7 digits in length) 440Hz on 100ms off 100ms on 100ms, repeated after 10 seconds


Busy Tone 480Hz + 620Hz 500ms on 500ms off


Reorder (in North America this is ITU E.182 Negative Indication Tone) 480Hz + 620Hz 250ms on 250ms pause


CAS Tone 2750Hz + 2130Hz for 80ms


3 burst stutter dial tone - 3 sequences of 350Hz+440Hz 100ms on 100ms off, then continuous dialtone (not included here, see below for dialtone)


Dial tone - continuous 350Hz + 440 Hz (this is 10 seconds when you should probably have digits dialed or go into a 'hang the phone up' tone)


AT&T Definity System 75/85 PABX Dial Tone - 250Hz + 400Hz continuous


CCITT 5 Seize sequence - 2600Hz + 2400Hz for 150ms with 150ms pause then 2400Hz for 150ms (timings can be different for different carriers)


CCITT 5 Seize sequence with 60Hz guard tone (used in some places, timings are carrier dependant and likely to be wrong for most carriers)


AU Congestion tone - with correct 10dB drop every second itteration - 420Hz for 375ms, then 375ms off, then 420Hz for 375ms 10dB down, then 375ms off.


Dialtone Deutsche Telekom Germany 425Hz (used for DISA, Callthru)


Script and Dialplan Examples


Calling from the dialplan is extremely simple: <action application="playback" data="tone_stream://<TGML>"/>

 <!-- UK Ring -->
 <action application="playback" data="tone_stream://%(400,200,400,450);%(400,2200,400,450)"/>
 <!-- UK Ring (Same as above, except plays twice)-->
 <action application="playback" data="tone_stream://%(400,200,400,450);%(400,2200,400,450);loops=2"/>

 <!-- US Ring -->
 <action application="playback" data="tone_stream://%(2000,4000,440,480)"/>
 <!-- US Busy -->
 <action application="playback" data="tone_stream://%(500,500,480,620)"/>


In Lua scripts, use the playback application with tone_stream:

--Lua example of busy tone
session:execute("playback", "tone_stream://%(500,500,480,620)");
--Lua example of a "bong" tone
BONG = "v=-7;%(100,0,941.0,1477.0);v=-7;>=2;+=.1;%(1000, 0, 640)";
BONG = "tone_stream://" .. BONG;
session:execute("playback", BONG);


In JavaScript you may use the "TeleTone" module or the playback application with tone_stream.
Example with TeleTone module:

// JavaScript example of a "BONG" tone using TeleTone
var BONG ="v=-7;%(100,0,941.0,1477.0);v=-7;>=2;+=.1;%(1000, 0, 640)";
var tts = new TeleTone(session);

Example with playback and tone_stream:

// JavaScript example of a "BONG" tone with playback and tone_stream
var BONG ="tone_stream://v=-7;%(100,0,941.0,1477.0);v=-7;>=2;+=.1;%(1000, 0, 640)";
session.execute("playback", BONG);


Perl is like Lua, just use the playback application with tone_stream:

#Perl example of busy tone
$session->execute("playback", "tone_stream://%(500,500,480,620)");
#Perl example of a "bong" tone
$BONG = "v=-7;%(100,0,941.0,1477.0);v=-7;>=2;+=.1;%(1000, 0, 640)";
$BONG = "tone_stream://" . $BONG;
$session->execute("playback", $BONG);

See Also