ProgramsToManipulateWavFiles - MRC CBU Language Wiki
location: ProgramsToManipulateWavFiles

Programs for manipulating wav files

There are four programs for manipulating wav files. There are versions of these programs for both DOS and unix. I advise using the unix versions. Although you can do almost everything these programs can do with Cool Edit, these programs enable you to automate many of these operations using Unix scripts. So, they are ideal if you want to perform the same operation on many files at once.

Executables for the linux machines are in /group/language/bin/linux windows executables can be downloaded from here (see bottom pf page).

  • infowav - prints out file information and cue locations

  • cuewav - adds or moves cues in a file

  • splice - splices out parts of a file

  • catwav - concatenates wav files retaining any markers or cues

You can put splice and catwav together in a script to perform cross-splicing of marked regions between files (see xsplice in the bin for an example). Typing the name of each prog with no arguments gives brief (too brief) description.

There is now a script called extract_all_cues in group/language/bin/linux. If you give it a wavfile name it will extract each of the marked regions in the file into it's own wav file, using the name of the marked region as the name of the file it is extracted to. If this script doesn't do exactly what you want you can make a copy in your own directory and modify it. For example, the script doesn't ramp the ends of the spliced section. It shouldn't be too much of a challenge to work out how to change this.

If /cbu/language/bin/linux is not on your path you have to run these programs by specifying the full path, e.g.

/group/language/bin/linux/infowav wavfilename

Alternatively you can add /group/language/bin/linux to your path by editing your .cshrc file in your home directory by adding the line:

set path=($path /group/language/bin/linux)

Here's another script that you might find handy. It can be used to add silence to the end of a file to pad it out to a given length (in this case 1 second):

INFILE=$1
# use infowav to get the duration of the input file (in ms) and subtract it from the duration you want the result to be
DURATION=`infowav $INFILE | awk '{if ($1 == "duration:") printf("%f\n", 1000 * (1.0-$2))}'`
rm -f tmp.wav tmp2.wav
# splice out the required amount of silence
splice 10sSilence22.5.wav -f 0,$DURATION  tmp.wav
#add a cue at the start of the silence
cuewav -off,0,10 tmp.wav tmp2.wav
# splice the silence with the cue onto the end of the input file
catwav -o $2 $1 tmp2.wav
# remove the temporary files
rm -f tmp.wav tmp2.wav

Put the text in a file, make it executable (chmod 0700 filename) then "filename inputfile outputfile" will create outputfile which will have the input file padded out with enough silence to make it exactly 1 second in length. Change the 1.0 in the 3rd line to use a different duration.

BEWARE unix shell scripts must NOT be in DOS format otherwise they won't work. So, if you create the script on a windows machine convert the file to unix format with "dos2unix filename"

The line "cuewav -off,0,10 tmp.wav tmp2.wav" puts a cue at the start of the added silence labeled "off". You can delete this and change subsequent occurrences of tmp2.wav to tmp.wav, but it's sometimes useful to mark the end of the original file. You'll need to create a file like 10sSilence22.5.wav which just contains 10s of silence (or as much as you need) at the same sample rate and number of channels as your input sound files. You can do this with CooldEdit, for example:

Note that some programs produce wav files that these programs don't like - sound files recorded by DMDX being one example. The simple fix is to convert these files to raw PCM files using sox (on unix) and then convert them back to wavs again. For e.g., to treat the ile original.wav

  • - a single channel wav file with a 22050 sampling rate, you would run the following commands:

sox original.wav tmp.raw

sox  -r 22050 -c 1 -w -s tmp.raw original.wav

See the sox man page for details.Note that you will lose any marks/cues in this process.

Download windows versions

-- Main.DennisNorris - 19 Apr 2006

CbuLanguage: ProgramsToManipulateWavFiles (last edited 2013-08-02 16:34:45 by RussellThompson)