[Nottingham] concatenating wav files

nottingham@mailman.lug.org.uk nottingham at mailman.lug.org.uk
Wed Apr 9 19:55:00 2003


James,

> Anyone know of a utility which will concatenate wav files? (cat 
> won't work due to the 44 byte header).

You could try using the wave module in python. Loop over the wav files and 
open each as wave_read objects, check that they have the same number of 
channels, sample width, framerate, etc.

Create a wave_write object with the correct parameters. Loop over the
input files again and read the frames and write them raw to the output 
file. Close the output file and it's job done as the number of frames is 
automatically corrected on close().

Or simply use SoX <http://sox.sourceforge.net/> and/or
shntool <http://www.etree.org/shnutils/shntool/>

Peter