<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/'>
	<channel>
		<title>The Corelatus Blog - Entries from June 2009</title>
		<description>Entries from June 2009</description>
                <link>../../../</link>

	
	<item>
		<title>Generating DTMF using a &amp;#039;player&amp;#039; on GTH</title>
		<link>../../../Generating_DTMF_using_a___039_player__039__on_GTH.html</link>        
		<guid isPermaLink="true">../../../Generating_DTMF_using_a___039_player__039__on_GTH.html</guid>
                <pubDate>Tue, 9 Jun 2009 12:31:17 +0200</pubDate>
		<description>&lt;p&gt;
The GTH can &lt;em&gt;transmit&lt;/em&gt; in-band signalling tones on a
timeslot. That&#39;s useful for testing and for building active in-band
signalling systems.
&lt;/p&gt;

&lt;h3&gt;DTMF&lt;/h3&gt;

&lt;p&gt;
The tones transmitted when the subscriber presses a number key on
fixed or mobile handset are called DTMF. Wikipedia has an &lt;a
href=&quot;http://en.wikipedia.org/wiki/DTMF&quot;&gt;article&lt;/a&gt; about it. To
generate DTMF, all we really need to know is that there are 16
possible DTMF signals, that each signal is made up of two sine waves
of particular frequencies and that sending the signal for 100ms is a
reasonable thing to do.
&lt;/p&gt;

&lt;p&gt;
Here&#39;s a .zip file with &lt;a
href=&quot;http://www.corelatus.com/~matthias/blog/dtmf_tones.zip&quot;&gt;DTMF
tones&lt;/a&gt; in it. Each file is raw ALAW data, i.e. it&#39;s ready for the
GTH to play (transmit) on a timeslot.
&lt;/p&gt;

&lt;p&gt;
The GTH has two ways of playing tones. One way is to stream the audio
data in over a TCP socket each time we want to play it. I wrote a &lt;a
href=&quot;http://blog.corelatus.com/2009/03/06/gth-audio-streaming-why-stream-over-tcp/&quot;&gt;post
about that&lt;/a&gt; earlier. The other way is to store the sample data on
the GTH and command its playback whenever it&#39;s needed. Since there&#39;s a
small number of different tones (12, or 16 if you want to use the
A/B/C/D tones as well) and the tones are short, storing them on the
GTH makes sense. To store the tone:
&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;&amp;lt;new&amp;gt;&amp;lt;clip &lt;/span&gt;&lt;span class=&quot;synType&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;synConstant&quot;&gt;&#39;dtmf5&#39;&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;&amp;gt;&amp;lt;/new&amp;gt;&lt;/span&gt;
(and now send the 800 byte file)
&lt;/code&gt;
&lt;/pre&gt;

to play the tone later on:

&lt;pre&gt;
&lt;code&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;&amp;lt;new&amp;gt;&amp;lt;player&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;synIdentifier&quot;&gt;&amp;lt;clip &lt;/span&gt;&lt;span class=&quot;synType&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;synConstant&quot;&gt;&#39;clip dtmf5&#39;&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;synIdentifier&quot;&gt;&amp;lt;pcm_sink &lt;/span&gt;&lt;span class=&quot;synType&quot;&gt;span&lt;/span&gt;=&lt;span class=&quot;synConstant&quot;&gt;&#39;3A&#39;&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt; &lt;/span&gt;&lt;span class=&quot;synType&quot;&gt;timeslot&lt;/span&gt;=&lt;span class=&quot;synConstant&quot;&gt;&#39;19&#39;&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;&amp;lt;/player&amp;gt;&amp;lt;/new&amp;gt;&lt;/span&gt; 
&lt;/code&gt;
&lt;/pre&gt;

&lt;h3&gt;Sequences of tones&lt;/h3&gt;

&lt;p&gt;
Sometimes you want to transmit a sequence of DTMF tones, for instance to simulate a subscriber dialling a number. The GTH lets you start a player with a sequence of tones like this:
&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;&amp;lt;new&amp;gt;&amp;lt;player&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;synIdentifier&quot;&gt;&amp;lt;clip &lt;/span&gt;&lt;span class=&quot;synType&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;synConstant&quot;&gt;&#39;clip dtmf5&#39;&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;/&amp;gt;&amp;lt;clip &lt;/span&gt;&lt;span class=&quot;synType&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;synConstant&quot;&gt;&#39;clip dtmf6&#39;&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;/&amp;gt;&amp;lt;clip &lt;/span&gt;&lt;span class=&quot;synType&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;synConstant&quot;&gt;&#39;clip dtmf8&#39;&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;/&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;synIdentifier&quot;&gt;&amp;lt;pcm_sink &lt;/span&gt;&lt;span class=&quot;synType&quot;&gt;span&lt;/span&gt;=&lt;span class=&quot;synConstant&quot;&gt;&#39;3A&#39;&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt; &lt;/span&gt;&lt;span class=&quot;synType&quot;&gt;timeslot&lt;/span&gt;=&lt;span class=&quot;synConstant&quot;&gt;&#39;19&#39;&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;&amp;lt;/player&amp;gt;&amp;lt;/new&amp;gt;&lt;/span&gt;
&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;
But that isn&#39;t a valid sequence of DTMF tones. Why not? Because DTMF
expects a gap between tones. The cleanest way to handle that is to
define another clip consisting of just silence and putting it between
each tone. A good &#39;silence&#39; value on E1 lines is 0x54. 60ms (480
samples) is a reasonable length.
&lt;/p&gt;

&lt;h3&gt;Other in-band tones&lt;/h3&gt;

&lt;p&gt;
DTMF in-band signalling is used in pretty much all handsets
(telephones), mostly for dialling, but also to navigate menus in IVR
systems. But before SS7 became popular, in-band signalling in the form
of CAS and SS5 was even used to communicate call setup information
between exchanges. GTH can also generate those tones, but that can be
the subject of another post.
&lt;/p&gt;
</description>
	</item>
	
        </channel>
</rss>

