Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-24-2009, 04:54 PM   #1
LQ Newbie
Registered: Apr 2009
Posts: 15

Rep: Reputation: 0
combine multiple wav files together with different sample rates / channels / bits

I have a folder with lots of wav files, all different samples/ rates/ bits

Most of them are just a mix of mono or stereo

is there a way using sox and bash, or another built in app that can convert them all to a uniform format?
Old 04-24-2009, 05:32 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Yes, of course ;-)

This page might give you some additional tips:

But my guess is you're going to have to figure out the "right" settings on a file-by-file basis, by trial and error...

Old 04-24-2009, 07:02 PM   #3
Senior Member
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96

Not 'built in', but if you've got a copy of mplayer...

if ! [ -e "$1" ]
    echo "$1 does not exist."
    echo "Exiting."
    exit 1


if file -L "$INFILE" | grep RIFF | grep PCM | grep "16 bit" | grep stereo | grep 44100 &> /dev/null
    echo "$INFILE is already a 44100Hz 16bit LE file."
    echo "Exiting."
    exit 0
if [ -e "$INFILE".wav ]
    echo "Decode output file: $INFILE.wav already exists."
    echo "Exiting."
    exit 1

if ! mplayer -vo null -vc null -af lavcresample=44100,channels=2,format=s16le -ao pcm:file="$INFILE".wav "$INFILE"
    echo "Couldn't decode $INFILE"
    echo "Exiting."
    exit 1
I called it 'any2wav' - run as:
$ for file in *; do any2wav "$file"; done
and it'll convert anything (even video audio tracks) to CD style .wav

I've got slightly different versions that do the same thing, but output mp3s or FLACs, if you're interested:


Last edited by ilikejam; 04-24-2009 at 07:04 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
combine multiple files into one file? baddah Linux - Newbie 10 09-06-2011 11:22 AM
Combine output of multiple files in one CSV file say_hi_ravi Programming 4 07-17-2008 03:04 AM
Can you combine multiple PDFs into one? Randux Linux - Software 8 11-21-2007 02:00 PM
Help! Combine multiple .odt documents yuliang Linux - Desktop 1 01-18-2007 05:34 PM
Combine multiple wmv files to one large file drkstr Linux - Software 4 04-26-2006 11:50 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:24 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration