Re: OT: sox help needed

2004-05-20 Thread Matthias Czapla
On Thu, May 20, 2004 at 04:58:52PM +0100, Colin Watson wrote:
> > mpg123 -s $i | sox -t raw -r 44100 -s -w -c 1 - \
> > -t wav -r 8000 -w -c 1 "`echo $i | sed -e 's/mp3$/wav/'`"
> 
> Quoted correctly:
> 
>   "`echo "$i" | sed -e 's/mp3$/wav/'`"
>
> A much simpler version of that if you know that $i ends with .mp3 is:
> 
>   "${i%.mp3}.wav"

Nice. I habitually use sed because most of the time there is much more
to do, like replacing spaces with underscores etc. And I have to thank
you Colin, because it has now become clear why my filename "repairs"
sometimes dont work. If it contains two space characters in a row and
the sed expression shall replace them with a single underscore for
example, it will not work without proper quoting because the two spaces
will become one when entering sed. Ive had lots of head scratching about
that :)

Regards
Matthias


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: OT: sox help needed

2004-05-20 Thread Jeff Elkins
On Thursday 20 May 2004 11:09 am, s. keeling wrote:
>Incoming from Jeff Elkins:
>> I'm trying to automate this:
>>
>> #!/bin/sh
>>
>> for i in *; do
>> if test -f $i; then
>> mpg123 -s $i | sox -t raw -r 44100 -s -w -c 1 - -t wav -r 8000 -w -c 1
>> $i.wav
>>
>> fi
>> done
>>
>> which works, but gives me: filename.mp3.wav - anyway to end up with
>> filename.wav?
>
>   #!/bin/sh
>   #
>   for i in *.mp3; do
>  if test -f $i; then
> NAME=$(basename $i .mp3)  # NOTE embedded space.
> mpg123 -s ${NAME}.mp3 | \
> sox -t raw -r 44100 -s -w -c 1 - -t wav -r 8000 -w -c 1
> ${NAME}.wav fi
>   done
>
>
>

Thanks for you help guys!

Jeff Ekins


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: OT: sox help needed

2004-05-20 Thread Colin Watson
On Thu, May 20, 2004 at 04:25:34PM +0200, Matthias Czapla wrote:
> On Thu, May 20, 2004 at 10:02:00AM -0400, Jeff Elkins wrote:
> > I'm trying to automate this:
> > 
> > #!/bin/sh
> > 
> > for i in *; do
> > if test -f $i; then
> > 
> > fi
> > done
> > 
> > which works, but gives me: filename.mp3.wav - anyway to end up with 
> > filename.wav?
> 
> Yes:
> 
> mpg123 -s $i | sox -t raw -r 44100 -s -w -c 1 - \
> -t wav -r 8000 -w -c 1 "`echo $i | sed -e 's/mp3$/wav/'`"

Quoted correctly:

  "`echo "$i" | sed -e 's/mp3$/wav/'`"

A much simpler version of that if you know that $i ends with .mp3 is:

  "${i%.mp3}.wav"

Cheers,

-- 
Colin Watson  [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: OT: sox help needed

2004-05-20 Thread s. keeling
Incoming from Jeff Elkins:
> 
> I'm trying to automate this:
> 
> #!/bin/sh
> 
> for i in *; do
> if test -f $i; then
> mpg123 -s $i | sox -t raw -r 44100 -s -w -c 1 - -t wav -r 8000 -w -c 1 $i.wav
> 
> fi
> done
> 
> which works, but gives me: filename.mp3.wav - anyway to end up with 
> filename.wav?

   #!/bin/sh
   #
   for i in *.mp3; do
  if test -f $i; then
 NAME=$(basename $i .mp3)  # NOTE embedded space.
 mpg123 -s ${NAME}.mp3 | \
 sox -t raw -r 44100 -s -w -c 1 - -t wav -r 8000 -w -c 1 ${NAME}.wav
  fi
   done


-- 
Any technology distinguishable from magic is insufficiently advanced.
(*)   http://www.spots.ab.ca/~keeling 
- -


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: OT: sox help needed

2004-05-20 Thread Matthias Czapla
On Thu, May 20, 2004 at 10:02:00AM -0400, Jeff Elkins wrote:
> I'm trying to automate this:
> 
> #!/bin/sh
> 
> for i in *; do
> if test -f $i; then
> 
> fi
> done
> 
> which works, but gives me: filename.mp3.wav - anyway to end up with 
> filename.wav?

Yes:

mpg123 -s $i | sox -t raw -r 44100 -s -w -c 1 - \
-t wav -r 8000 -w -c 1 "`echo $i | sed -e 's/mp3$/wav/'`"

Some thoughts: Quote all occurences of $i if youre not absolutely sure
that the filenames dont contain any special characters like whitespace etc.
The sox command will only work correctly if the MP3 file has a sample rate
of 44100 Hertz. If this is not the case for all the files you will need
some way to determine the sample rate before the conversion and give sox
the actual input sample rate on the command line. Another possibility is
to decode the MP3 to a temporary WAVE file and use that as the input to
sox so it can determine the sample rate automatically.

Regards
Matthias


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: OT: sox help needed

2004-05-20 Thread Jeff Elkins
On Thursday 20 May 2004 08:34 am, Matthias Czapla wrote:
>On Thu, May 20, 2004 at 04:43:48AM -0400, Jeff Elkins wrote:
>> I need to convert a mess of mp3 files into PCM 8000 kHz, 16 Bit, Mono wav
>> format. I tried using mpg123 and sox :
>>
>> mpg123 -b 1 -s test.mp3 | sox -t raw -r 8000 -s -w -c 2 - test.wav
>>
>> w/o success. The resulting wav file is molasses slow.
>
>The syntax of sox is:
>sox [INPUT file options] input_file [OUTPUT file options] output_file
>
>You told sox that the input would be 16 Bit 8 kHz stereo, which it
>probably is not. Try something like this:
>
>mpg123 -s test.mp3 | sox -t raw -r 44100 -s -w -c 2 - \
>-t wav -r 8000 -w -c 1 out.wav
>
>Regards
>Matthias

Thanks!

I'm trying to automate this:

#!/bin/sh

for i in *; do
if test -f $i; then
mpg123 -s $i | sox -t raw -r 44100 -s -w -c 1 - -t wav -r 8000 -w -c 1 $i.wav

fi
done

which works, but gives me: filename.mp3.wav - anyway to end up with 
filename.wav?

Thanks again,

Jeff Elkins


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: OT: sox help needed

2004-05-20 Thread Matthias Czapla
On Thu, May 20, 2004 at 04:43:48AM -0400, Jeff Elkins wrote:
> I need to convert a mess of mp3 files into PCM 8000 kHz, 16 Bit, Mono wav 
> format. I tried using mpg123 and sox :
> 
> mpg123 -b 1 -s test.mp3 | sox -t raw -r 8000 -s -w -c 2 - test.wav
> 
> w/o success. The resulting wav file is molasses slow. 

The syntax of sox is:
sox [INPUT file options] input_file [OUTPUT file options] output_file

You told sox that the input would be 16 Bit 8 kHz stereo, which it
probably is not. Try something like this:

mpg123 -s test.mp3 | sox -t raw -r 44100 -s -w -c 2 - \
-t wav -r 8000 -w -c 1 out.wav

Regards
Matthias


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



OT: sox help needed

2004-05-20 Thread Jeff Elkins
I need to convert a mess of mp3 files into PCM 8000 kHz, 16 Bit, Mono wav 
format. I tried using mpg123 and sox :

mpg123 -b 1 -s test.mp3 | sox -t raw -r 8000 -s -w -c 2 - test.wav

w/o success. The resulting wav file is molasses slow. 

Any help appreciated. thanks!

Jeff Elkins


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]