<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2160/3/7/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+10+Codecs+and+Audio+Formats">Asterisk 10 Codecs and Audio Formats</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~mdavenport">Malcolm Davenport</a>
    </h4>
        <br/>
                         <h4>Changes (0)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="Asterisk10CodecsandAudioFormats-Overview"></a>Overview</h2>

<p>As a part of the <a href="/wiki/display/AST/Media+Overhaul" title="Media Overhaul">Media Overhaul</a> project for Asterisk 1.10, changes have been made to Asterisk to increase the number of codecs it's capable of supporting, to handle codecs with custom formats, and to support audio sampling rates greater than 16kHz.  This has resulted in several practical changes to Asterisk that will benefit its users.</p>

<h4><a name="Asterisk10CodecsandAudioFormats-ExpandedSignedLinearSupport"></a>Expanded Signed Linear Support</h4>

<p>Versions of Asterisk prior to 1.10 supported 16-bit Signed Linear sampled at 8kHz and at 16kHz (versions 1.6.0 - 1.8).  New to Asterisk 1.10 is support for a much wider range of sampling rates.  Asterisk can resample between any of these sampling rates and can read/write raw 16-bit signed linear audio files from/to disk.  The complete list of supported sampling rates and file format extensions is:</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Sampling Rate </th>
<th class='confluenceTh'>Asterisk File format</th>
</tr>
<tr>
<td class='confluenceTd'> 8kHz </td>
<td class='confluenceTd'> .sln </td>
</tr>
<tr>
<td class='confluenceTd'> 12kHz </td>
<td class='confluenceTd'> .sln12 </td>
</tr>
<tr>
<td class='confluenceTd'> 16kHz </td>
<td class='confluenceTd'> .sln16 </td>
</tr>
<tr>
<td class='confluenceTd'> 24kHz </td>
<td class='confluenceTd'> .sln24 </td>
</tr>
<tr>
<td class='confluenceTd'> 32kHz </td>
<td class='confluenceTd'> .sln32 </td>
</tr>
<tr>
<td class='confluenceTd'> 44.1kHz </td>
<td class='confluenceTd'> .sln44 </td>
</tr>
<tr>
<td class='confluenceTd'> 48kHz </td>
<td class='confluenceTd'> .sln48 </td>
</tr>
<tr>
<td class='confluenceTd'> 96kHz </td>
<td class='confluenceTd'> .sln96 </td>
</tr>
<tr>
<td class='confluenceTd'> 192kHz </td>
<td class='confluenceTd'> .sln192 </td>
</tr>
</tbody></table>
</div>


<p>Asterisk 1.10 removes the format_sln16 file format in favor of expanded support in the main format_sln file format for all sampling rates.  So, users who notice the absence of format_sln16 from their Asterisk 1.10 builds should not panic.</p>

<p>Users can create 16-bit Signed Linear files of varying sampling rates from WAV files using the sox command-line audio utility.  </p>

<ul>
        <li>SOX example</li>
</ul>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>sox input.wav -t raw -b 16 -r 32000 output.sln
mv output.sln output.sln32
</pre>
</div></div>

<p>In this example, an input WAV file has been converted to Signed Linear at a depth of 16-bits and at a rate of 32kHz.  The resulting output.sln file is then renamed output.sln32 so that it can be processed correctly by Asterisk.</p>

<h4><a name="Asterisk10CodecsandAudioFormats-32kHzSpeexSupport"></a>32kHz Speex Support</h4>

<p>Asterisk versions prior to 1.8 supported 8kHz Speex. Asterisk 1.8 supports 8 and 16kHz Speex.  Asterisk 1.10 now supports 8, 16, and 32kHz Speex.  Use of the 32kHz Speex mode is, like the other modes, controlled in the respective channel driver's configuration file, e.g. chan_sip's sip.conf.</p>

<ul>
        <li>Speex Example</li>
</ul>


<p>sip.conf</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[mypeer]
type=peer
secret=mysupersecret!!!
host=dynamic
context=fancycalls
disallow=all
allow=speex

[mypeer2]
type=peer
secret=myothers3cr3t
host=dynamic
context=fancycalls
disallow=all
allow=speex16

[mypeer3]
type=peer
secret=passwordisaterriblepassword
host=dynamic
context=fancycalls
disallow=all
allow=speex32
</pre>
</div></div>

<p>In this example, we have created three SIP peers for 3 different devices.  The first, mypeer, supports only the 8kHz sampling of Speex; the second, mypeer2, supports only the 16kHz sampling of Speex; and the third, mypeer3, supports the new 32kHz sampling of Speex.</p>

<p>For comparison, here are some Speex samples, saved as WAV files in .mov containers, for easy-of-playback.</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<td class='confluenceTd'>8kHz <div class="embeddedObject" >
    <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="https://www.apple.com/qtactivex/qtplugin.cab" data="/wiki/download/attachments/17203260/8kHz-Speex.mov" height="20" type="video/quicktime" width="100">
                <param name="autostart" value="false">
                     <param name="autoplay" value="false">
                     <param name="data" value="/wiki/download/attachments/17203260/8kHz-Speex.mov">
                     <param name="src" value="/wiki/download/attachments/17203260/8kHz-Speex.mov">
                     <param name="type" value="video/quicktime">
                 <embed autostart="false" autoplay="false" height="20" pluginspage="https://www.apple.com/quicktime/download/" src="/wiki/download/attachments/17203260/8kHz-Speex.mov" type="video/quicktime" width="100">
    </embed>
                        </object>

</div>
 </td>
<td class='confluenceTd'>16kHz <div class="embeddedObject" >
    <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="https://www.apple.com/qtactivex/qtplugin.cab" data="/wiki/download/attachments/17203260/16kHz-Speex.mov" height="20" type="video/quicktime" width="100">
                <param name="autostart" value="false">
                     <param name="autoplay" value="false">
                     <param name="data" value="/wiki/download/attachments/17203260/16kHz-Speex.mov">
                     <param name="src" value="/wiki/download/attachments/17203260/16kHz-Speex.mov">
                     <param name="type" value="video/quicktime">
                 <embed autostart="false" autoplay="false" height="20" pluginspage="https://www.apple.com/quicktime/download/" src="/wiki/download/attachments/17203260/16kHz-Speex.mov" type="video/quicktime" width="100">
    </embed>
                        </object>

</div>
 </td>
<td class='confluenceTd'>32kHz <div class="embeddedObject" >
    <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="https://www.apple.com/qtactivex/qtplugin.cab" data="/wiki/download/attachments/17203260/32kHz-Speex.mov" height="20" type="video/quicktime" width="100">
                <param name="autostart" value="false">
                     <param name="autoplay" value="false">
                     <param name="data" value="/wiki/download/attachments/17203260/32kHz-Speex.mov">
                     <param name="src" value="/wiki/download/attachments/17203260/32kHz-Speex.mov">
                     <param name="type" value="video/quicktime">
                 <embed autostart="false" autoplay="false" height="20" pluginspage="https://www.apple.com/quicktime/download/" src="/wiki/download/attachments/17203260/32kHz-Speex.mov" type="video/quicktime" width="100">
    </embed>
                        </object>

</div>
</td>
</tr>
</tbody></table>
</div>


<h4><a name="Asterisk10CodecsandAudioFormats-CELTPassthroughSupport"></a>CELT Pass-through Support</h4>

<p>Asterisk 1.10 adds pass-through support for the CELT codec.  CELT provides low-delay transmission of high-quality audio.  Unlike many other codecs that are focused on the transmission of human speech only, CELT is suitable for the transmission of both speech and audio, e.g. music.</p>

<p>Because the CELT codec is being folded, along with SILK, into a future codec called OPUS, and because the CELT bitstream isn't finalized, we have chosen not to add transcoding support for CELT as this time.  CELT is configured in codecs.conf with the following parameters.</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Option </th>
<th class='confluenceTh'>Values </th>
<th class='confluenceTh'>Description</th>
</tr>
<tr>
<td class='confluenceTd'> type </td>
<td class='confluenceTd'> celt </td>
<td class='confluenceTd'> Sets the CELT codec as the type of codec being configured </td>
</tr>
<tr>
<td class='confluenceTd'> samprate </td>
<td class='confluenceTd'> 32000, 441000, 48000 </td>
<td class='confluenceTd'> Defines the sampling rate in Hz to be used for the defined codec </td>
</tr>
<tr>
<td class='confluenceTd'> framesize </td>
<td class='confluenceTd'> factors of 2 </td>
<td class='confluenceTd'> Represents the duration of each frame in samples.  Defaults to 480 and should only be defined if a client does not use the default size.  This option allows the codec to split 20ms frames into multiple frames in an anticipatory way.  Thus, with 20ms frames at 48kHz are 960 samples, the packet is large.  So setting framesize to 480, 20ms frames are transmitted in two 480 sample packets. </td>
</tr>
</tbody></table>
</div>



<h5><a name="Asterisk10CodecsandAudioFormats-CELTcodecs.confexample"></a>CELT codecs.conf example</h5>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[celt32]
type=celt
samprate=32000

[celt44]
type=celt
samprate=44100

[celt48]
type=celt
samprate=48000
</pre>
</div></div>

<p>In this example, three different CELT codecs are created: one for 32kHz mode, one for 44kHz mode, and another for 48kHz mode.  </p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>These codecs cannot be dynamically changed while Asterisk is running.  In order to make changes, an Asterisk restart is required.</td></tr></table></div>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>To make sure a codec or format is setup correctly, you can execute:
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>core show codecs
</pre>
</div></div>
<p>from the Asterisk CLI</p></td></tr></table></div>

<h5><a name="Asterisk10CodecsandAudioFormats-CELTsip.confexample"></a>CELT sip.conf example</h5>

<p>Corresponding SIP peer entries to use the CELT codec would look like:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[myceltpeer1]
type=peer
secret=passwordisstillaterriblepassword
host=dynamic
context=fancycalls
disallow=all
allow=celt32

[myceltpeer2]
type=peer
secret=momnowaitdontmakemomyourpassword
host=dynamic
context=fancycalls
disallow=all
allow=celt44

[myceltpeer3]
type=peer
secret=daddontmakedadyourpasswordeither
host=dynamic
context=fancycalls
disallow=all
allow=celt48
</pre>
</div></div>

<p>In this case, we have defined 3 peers, each with a different CELT sampling rate.  Thus, you'd probably want to set at least two of them to the same CELT rate, so they could call each other.</p>

<p>For CELT-calling, there are not a host of options on the client side.  One could try Ekiga or SFLphone as softclients to make CELT calls.</p>

<h4><a name="Asterisk10CodecsandAudioFormats-SILKSupport"></a>SILK Support</h4>

<p>Asterisk 1.10 provides full support for Skype's SILK codec.  SILK is an extremely flexible codec for the transmission of speech.  It operates in low bitrate narrow-band modes as well as higher (but still very low, otherwise) bitrate super wide-band modes.  With respect to CPU complexity, its consumption is roughly three times that of G.729a at comparable bitrates.</p>

<p>SILK is configured in codecs.conf with the following parameters</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Option </th>
<th class='confluenceTh'>Values </th>
<th class='confluenceTh'>Description</th>
</tr>
<tr>
<td class='confluenceTd'> type </td>
<td class='confluenceTd'> silk </td>
<td class='confluenceTd'> Sets the SILK codec as the type of codec being configured </td>
</tr>
<tr>
<td class='confluenceTd'> samprate </td>
<td class='confluenceTd'> 8000, 12000, 16000, 24000 </td>
<td class='confluenceTd'> Defines the sampling rate in Hz to be used for the defined codec </td>
</tr>
<tr>
<td class='confluenceTd'> fec </td>
<td class='confluenceTd'> true, false </td>
<td class='confluenceTd'> Sets the use of Forward Error Correction by the codec.  Off by default. </td>
</tr>
<tr>
<td class='confluenceTd'> packetloss_percentage </td>
<td class='confluenceTd'> Integer as a percent </td>
<td class='confluenceTd'> Defines the estimated packetloss in the uplink direction.  This parameter affects the amount of redundancy built into SILK when fec is enabled.  The larger the amount, the higher the consumed bandwidth.  Default is 0.  10 is recommended when fec is enabled </td>
</tr>
<tr>
<td class='confluenceTd'> maxbitrate </td>
<td class='confluenceTd'> 8kHz: 5000-20000, 12kHz: 7000-25000, 16kHz: 8000-30000, 24kHz: 20000-40000 </td>
<td class='confluenceTd'> Defines, in bps and per the sampling rate being used, the maximum bitrate that will be consumed by the codec </td>
</tr>
<tr>
<td class='confluenceTd'> dtx </td>
<td class='confluenceTd'> true, false </td>
<td class='confluenceTd'> Defines whether encoding is done in discontinuous transmission mode.  If enabled, bandwidth will be reduced during periods of silence, but additional CPU complexity will be required.  Off by default </td>
</tr>
</tbody></table>
</div>


<h5><a name="Asterisk10CodecsandAudioFormats-SILKcodecs.confexample"></a>SILK codecs.conf example</h5>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[silk8]
type=silk
samprate=8000
fec=true
packetloss_percentage=10
maxbitrate=20000
dtx=false

[silk12]
type=silk
samprate=12000
fec=true
packetloss_percentage=10
maxbitrate=25000
dtx=false

[silk16]
samprate=16000
fec=true
packetloss_percentage=10
maxbitrate=30000
dtx=false

[silk24]
samprate=24000
fec=true
packetloss_percentage=10
maxbitrate=40000
dtx=false
</pre>
</div></div>

<p>In this example, four different SILK codecs are created: one each for 8 (silk8), 12 (silk12), 16 (silk16), and 24kHz (silk24).</p>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>These codecs cannot be dynamically changed while Asterisk is running.  In order to make changes, an Asterisk restart is required.</td></tr></table></div>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>To make sure a codec or format is setup correctly, you can execute:
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>core show codecs
</pre>
</div></div>
<p>from the Asterisk CLI</p></td></tr></table></div>

<h5><a name="Asterisk10CodecsandAudioFormats-SILKsip.confexample"></a>SILK sip.conf example</h5>

<p>Corresponding SIP peer entries to use the SILK codec would look like:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[mysilkpeer1]
type=peer
secret=thanksdigium
host=dynamic
context=fancycalls
disallow=all
allow=silk8

[mysilkpeer2]
type=peer
secret=forgivingme
host=dynamic
context=fancycalls
disallow=all
allow=silk12

[mysilkpeer3]
type=peer
secret=suchexcellentsoftware
host=dynamic
context=fancycalls
disallow=all
allow=silk16

[mysilkpeer4]
type=peer
secret=touse
host=dynamic
context=fancycalls
disallow=all
allow=silk24
</pre>
</div></div>

<p>In this case, we have defined 4 peers, each with a different SILK codec.</p>

<p>To our knowledge, there are no generally available SILK softphones (except for CSIPSimple) or hardphones - the Skype client itself doesn't count as it can only be connected to the Skype network.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+10+Codecs+and+Audio+Formats">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=17203260&revisedVersion=16&originalVersion=15">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+10+Codecs+and+Audio+Formats?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>