[asterisk-users] Re: Ringtone/gentone/busy and g729

Tony Mountifield tony at softins.clara.co.uk
Fri Aug 18 09:32:59 MST 2006


In article <44E5D98F.701 at krisk.org>,
Kristian Kielhofner <kris at krisk.org> wrote:
> Hello everyone,

Hi Kris

> 	I am still on my quest to build a g729 compatible (yet license free) 
> Asterisk system.
> 
> 	Here is the latest...  It seems that when Asterisk needs to indicate 
> ringing or busy to a SIP channel that has already been answered (like 
> with an IVR) it plays back audio using the values in ringtone.h and 
> busy.h (generated by gentone during compilation).  It seems that these 
> are stored internally as ulaw audio files, and Asterisk simply plays 
> them back when needed.

Looking at those two files, it would appear they are slin data.

> 	What I would like to do, as a hack (for now), is have a MOH class 
> called ringtone (I'm not worried about busy - yet) with some .g729 files 
> that are an EXACT replica of those ulaw files from above, just converted 
> to g729 (I can handle that part).  That way I can just use m(ringtone) 
> as an argument to Dial().
> 
> 	So, the final questions are:
> 
> 1)  Is my understanding of this "problem" correct?
> 
> 2)  Is this the simplest fix, or am I making this more complicated than 
> it needs to be?  I know that I can find some ringtones on the web, but I 
> would like to have an EXACT replica of what Asterisk uses.
> 
> 3)  How can I get the sounds used by Asterisk from ringtone.h and busy.h 
> in a ulaw (or slin) file?

OK, create a script called samples.pl containing the following:

#!/usr/bin/perl
$times = shift || 1;
undef $/;
$data = <>;
$data =~ /{\s*(.*?)\s*}/s;
@samples = split /[^0-9-]+/,$1;
print pack('v*', at samples) x $times;
#--end--

This will read busy.h or ringtone.h and output the values as a raw slin file.
You can pass a repeat count to samples.pl if you want to make a longer file.
You can convert that to whatever format you like using sox, e.g. for .wav:

samples.pl 50 <busy.h | sox -t raw -sw -c1 -r8000 - busy.wav
samples.pl 100 <ringtone.h | sox -t raw -sw -c1 -r8000 - ringtone.wav

Change .wav to .ul or .al for uLaw or aLaw output.

Hope this helps!

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-users mailing list