LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 04-24-2009, 04:54 PM   #1
PiNPOiNT
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
paulsm4
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:

http://dsl.org/cookbook/cookbook_29.html

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...

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

Rep: Reputation: 96
Hi.

Not 'built in', but if you've got a copy of mplayer...
Code:
#!/bin/bash

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

INFILE="$1"

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

if ! mplayer -vo null -vc null -af lavcresample=44100,channels=2,format=s16le -ao pcm:file="$INFILE".wav "$INFILE"
    then
    echo "Couldn't decode $INFILE"
    echo "Exiting."
    exit 1
fi
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:

http://www.ilikejam.org/blog/unix/scripts.html

Dave

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


Reply


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


All times are GMT -5. The time now is 07:17 PM.

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