[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Swiss Army Knife of Sound has me Baffled.



I have a little shell script called fullstereo which works fine.
It's short so I'll show it to you.  It records sound from a
Creative Labs usb sound card which is probably much happier on a
Windows box but that's not where I need it.  It has only 1
sampling rate that works under debian and that is 48 KHZ.  I want
44.1 KHZ and I get 2 good stereo channels with the following script:

#! /bin/sh
cd ~/tmp
filename=$1.wav
echo $filename
arecord -D hw:1,0 -r 48000 -d $2 -c 2 -f S16_LE - \
| sox -t wav - -r44100 $filename

	$2 is a value in seconds, minutes or hours and it goes
like a house on fire with no problem.

	So, I want a mono version.  Let's try this:

#! /bin/sh
cd ~/tmp
filename=$1.wav
echo $filename
arecord -D hw:1,0 -r 48000 -d $2 -c 1 -f S16_LE - \
| sox -t wav - -r44100 $filename

This hasn't worked yet.  It is identical to the good version but
for c 1 as the number of channels to arecord instead of c 2 .

	When running that script, this is what happens:

$ ./highmono testsound 30
testsound.wav
Recording WAVE '-' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono

#Good so far and then

arecord: set_params:1345: Channels count non available
sox FAIL formats: can't open input  `-': WAVE: RIFF header not found

Darn!  A couple of microseconds before that, the same process
understood what I asked it to do.  When the -c parameter was set
to 2, it understood what to do with the standard output but with
c set to 1, it did what you see above.

	I can't seem to figure out why 1 channel output is any
different from 2 channel except that the wav header should be
pretty much the same with a channel count of 1 instead of 2.

	The man page for arecord even says the following:

       -c, --channels=#
	      The number of channels.  The default is one channel.  Valid val‐
	      ues are 1 through 32.  Theoretically, one could
leave out -c 1 and it should go ahead as if that flag was
actually there but it breaks instead.  This might also be because
one can not set any parameters without the Windows driver and I
guess I could leave it in stereo mode and tell sox to mix the
left and right channels which is fine with me but kind of clunky.

	I am asking the list's wisdom in case there is a better
way to produce the mono channel.

	Thanks.

Martin     WB5AGZ


Reply to: