[asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Quy Pham Sy
Hi all,

I have to play a alaw file with .wav ext. How can I do this?
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Danny Nicholas
  _  

From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Quy Pham Sy
Subject: [asterisk-users] play alaw file with .wav extension

 

I have to play a alaw file with .wav ext. How can I do this? 

Use the asterisk convert command or SOX.

 

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Quy Pham Sy
Hi,

The files are actually alaw file (i check by file command). they're,
however, named with .wav extension, and these file are inherented with
current system I'm not allow to change these.

Quy

On Wed, Jul 21, 2010 at 8:12 PM, Danny Nicholas da...@debsinc.com wrote:

   --

 *From:* asterisk-users-boun...@lists.digium.com [mailto:
 asterisk-users-boun...@lists.digium.com] *On Behalf Of *Quy Pham Sy
 *Subject:* [asterisk-users] play alaw file with .wav extension



 I have to play a alaw file with .wav ext. How can I do this?

 Use the asterisk “convert” command or SOX.



 --
 _
 -- Bandwidth and Colocation Provided by http://www.api-digital.com --
 New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

 asterisk-users mailing list
 To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Danny Nicholas
Asterisk won't be happy trying to play foobar.wav if it is actually a
.alaw file.   Since you can't rename the existing files, there's no law that
says you can't copy them and play them correctly.Assuming that your
calls are using the alaw codec, this snippet would do the trick

 

Exten = 1234,1,answer

Exten = 1234,n,System(/bin/cp foobar.wav /tmp/foobar.alaw)

Exten = 1234,n,playback(/tmp/foobar)

Exten = 1234,n,System(/bin/rm /tmp/foobar.alaw)

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Kevin P. Fleming
On 07/21/2010 04:35 PM, Danny Nicholas wrote:
 Asterisk won’t be “happy” trying to play foobar.wav if it is actually a
 .alaw file.   Since you can’t rename the existing files, there’s no law
 that says you can’t copy them and play them correctly.Assuming that
 your calls are using the alaw codec, this snippet would do the trick
 
  
 
 Exten = 1234,1,answer
 
 Exten = 1234,n,System(/bin/cp foobar.wav /tmp/foobar.alaw)
 
 Exten = 1234,n,playback(/tmp/foobar)
 
 Exten = 1234,n,System(/bin/rm /tmp/foobar.alaw)

No, that won't work either, because a WAV file has a header, and a raw
alaw file does not... so Asterisk will try to play the contents of that
header as alaw data, presumably producing terrible noise.

The best you can do is to use sox to convert them from
alaw-in-WAV-container to raw-alaw.

-- 
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: kflem...@digium.com
Check us out at www.digium.com  www.asterisk.org

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Quy Pham Sy
 Exten = 1234,n,System(/bin/cp foobar.wav /tmp/foobar.alaw)

it actually works, I made a link to the .wav file instead of copying it
ln -s foobar.wav foobar.alaw, and it works well.


No, that won't work either, because a WAV file has a header, and a raw
alaw file does not... so Asterisk will try to play the contents of that
header as alaw data, presumably producing terrible noise.

My .wav files are alaw file indeed. Here is the output from file command

$file 53.wav
53.wav: RIFF (little-endian) data, WAVE audio, ITU G.711 A-law, mono 8000 Hz

they've just named as xxx.wav so I guess there is no problems with copying
or linking solutions.

Thanks all,

On Wed, Jul 21, 2010 at 9:50 PM, Kevin P. Fleming kpflem...@digium.comwrote:

 On 07/21/2010 04:35 PM, Danny Nicholas wrote:
  Asterisk won’t be “happy” trying to play foobar.wav if it is actually a
  .alaw file.   Since you can’t rename the existing files, there’s no law
  that says you can’t copy them and play them correctly.Assuming that
  your calls are using the alaw codec, this snippet would do the trick
 
 
 
  Exten = 1234,1,answer
 
  Exten = 1234,n,System(/bin/cp foobar.wav /tmp/foobar.alaw)
 
  Exten = 1234,n,playback(/tmp/foobar)
 
  Exten = 1234,n,System(/bin/rm /tmp/foobar.alaw)

 No, that won't work either, because a WAV file has a header, and a raw
 alaw file does not... so Asterisk will try to play the contents of that
 header as alaw data, presumably producing terrible noise.

 The best you can do is to use sox to convert them from
 alaw-in-WAV-container to raw-alaw.

 --
 Kevin P. Fleming
 Digium, Inc. | Director of Software Technologies
 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
 skype: kpfleming | jabber: kflem...@digium.com
 Check us out at www.digium.com  www.asterisk.org

 --
 _
 -- Bandwidth and Colocation Provided by http://www.api-digital.com --
 New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

 asterisk-users mailing list
 To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Benny Amorsen
Quy Pham Sy qu...@vega.com.vn writes:

 they've just named as xxx.wav so I guess there is no problems with copying
 or linking solutions.

You're simply lucky that the header is short enough to not sound too
bad.


/Benny


-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Danny Nicholas
1. Sometimes it's ok to be lucky
2. my SOX (1.14.0) on CENTOS doesn't handle alaw files.


-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Steve Edwards

Un-top-posting and trying to regurgitate into a cohesive thread...

On Wed, 21 Jul 2010, Quy Pham Sy wrote:


I have to play a alaw file with .wav ext. How can I do this?


On Wed, 21 Jul 2010, Danny Nicholas wrote:

Asterisk won’t be “happy” trying to play foobar.wav if it is actually a 
.alaw file. Since you can’t rename the existing files, there’s no law 
that says you can’t copy them and play them correctly. Assuming that 
your calls are using the alaw codec, this snippet would do the trick


Exten = 1234,1,answer
Exten = 1234,n,System(/bin/cp foobar.wav /tmp/foobar.alaw)
Exten = 1234,n,playback(/tmp/foobar)
Exten = 1234,n,System(/bin/rm /tmp/foobar.alaw)


On Wed, 21 Jul 2010, Kevin P. Fleming wrote:

No, that won't work either, because a WAV file has a header, and a raw 
alaw file does not... so Asterisk will try to play the contents of that 
header as alaw data, presumably producing terrible noise.


The best you can do is to use sox to convert them from 
alaw-in-WAV-container to raw-alaw.


On Wed, 21 Jul 2010, Quy Pham Sy wrote:


 Exten = 1234,n,System(/bin/cp foobar.wav /tmp/foobar.alaw)

it actually works, I made a link to the .wav file instead of copying it 
ln -s foobar.wav foobar.alaw, and it works well.


My .wav files are alaw file indeed. Here is the output from file command

$file 53.wav
53.wav: RIFF (little-endian) data, WAVE audio, ITU G.711 A-law, mono 
8000 Hz


they've just named as xxx.wav so I guess there is no problems with 
copying or linking solutions.


It only appears to be working because you can't hear the problem.

Your files are not mis-named, they are formatted in a way that Asterisk 
doesn't handle. Asterisk understands A-LAW encoding, just not when it's in 
a WAV container.


(There is no such thing as an alaw file. You may be thinking of a
raw (header-less) file containing A-LAW encoded data.)

By tricking Asterisk into playing the file as a header-less file, 
Asterisk is processing the WAV header as A-LAW encoded data. A WAV file 
has a 44 byte header. An A-LAW sample is 1 byte (not real sure about 
that). The sample rate is 8,000 per second. The 44 samples are played in 
about 1/200th of a second so you don't hear the noise at the beginning 
of the file.


You can create an A-LAW in WAV file using:

sox\
/var/lib/asterisk/sounds/demo-congrats.wav\
-A\
-t wav\
alaw-in-wav.wav

If you extract the header using:

dd\
bs=44\
count=1\
if=alaw-in-wav.wav\
of=header.wav

And then concatenate a bunch of them:

for ((IDX = 0; IDX  200; ++IDX))
do
cat header.wav
done noise.alaw

And then convert this into a more normal WAV file:

sox -t al noise.alaw -s -w noise.wav

You can play this in most audio players and hear about 1 second of a not 
too annoying buzz.


The proper way to handle this would be to enhance 
format_wav.c/format_wav_gsm.c to handle A-LAW encoded data.


Another approach would be to write an AGI (playback-alaw-in-wav?) to 
wrap the create a link, play the file, delete the link band-aid. You 
could do in dialplan, I just prefer writing code where I have more 
flexibility and better error handling.


--
Thanks in advance,
-
Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
Newline  Fax: +1-760-731-3000-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Philipp von Klitzing
Hi!

 2. my SOX (1.14.0) on CENTOS doesn't handle alaw files.

It surely does, only that you need to tell it explicitely to:
Use -t ul or -t al and you are fine.

Philipp


-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] play alaw file with .wav extension

2010-07-21 Thread Steve Edwards
On Wed, 21 Jul 2010, Danny Nicholas wrote:

 2. my SOX (1.14.0) on CENTOS doesn't handle alaw files.

Do you mean read or write?

Do you mean a raw (header-less) file containing A-LAW encoded data or 
A-LAW encoded data in a WAV formatted file?

While some of the options are a bit obtuse (like silence), sox should 
have enough command line options to handle just about any format and any 
encoding.

-- 
Thanks in advance,
-
Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
Newline  Fax: +1-760-731-3000

-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users