[linux-audio-user] Copying one channel from a Stereo File with sox

wes schreiner wes at infosink.com
Sun Jun 27 20:46:36 EDT 2004


Martin McCormick wrote:

>	This appears to be right on target except I am going to need
>to play a bit with the input file and probably name it something else
>than a .wav file.
>
>	I connected a stereo tape recorder to the two inputs of the
>sound card and used the following command to capture 2 tracks of audio
>containing separate program material recorded at 1-and-7/8 IPS.
>That's the reason for the low sample rate:
>
>arecord -d 86400 -t wav -r 8000 -F S8 -c 2 2channelarchive.wav
>  
>

You must mean:

arecord -d 86400 -t wav -r 8000 -f S8 -c 2 2channelarchive.wav


-f is format, -F is period time.

Why create a 2-channel file only to split them? Why not:

arecord -d 86400 -t wav -r 8000 -f S8 -c 2 -I ch1.wav ch2.wav


I see another problem. It appears that arecord is not putting a proper
WAV file header on the output file(s). That might be why sox is getting 
a little confused. When you run acrecord and it says "Recording raw 
data..." that's what the output file is, despite the "-t wav" argument. 
If arecord says "Recording WAVE...." then your output file has a proper 
header.

Further, if you run arecord with the argument "-F S8" you really get 
unsigned 8 bit output.  arecord won't accept "-f S8" while "-F S8" is 
silently ignored and you get unsigned 8 bit output anyway. So the 
command I have above doesn't actually work, arecord says "arecord: 
begin_wave:1612: Wave doesn't support S8 format...", but this works:

arecord -d 86400 -t wav -r 8000 -f U8 -c 2 -I ch1.wav ch2.wav


except that ch1.wav and ch2.wav are raw, headerless files, without WAV 
headers. sox doesn't like to see raw, headerless files with names ending 
in .wav, but once I rename ch1.wav and ch2.wav to ch1.raw, ch2.raw I can 
use sox to put a proper WAV header on the files with:

sox -r 8000 -u -b ch1.raw ch1.wav


Alternately, arecord does create a proper 2-channel WAV file, so you 
could record with this:

arecord -d 86400 -t wav -r 8000 -f U8 -c 2 twochan.wav


And then split it with:

sox twochan.wav -c 1 leftchan.wav avg -l


And your resulting leftchan.wav will be 8 bit, unsigned, 8000 
sample/sec, with a proper WAV header.

wes





More information about the Linux-audio-user mailing list