SOX and fade in and fade out
From the sox manpage:
fade [type] fade-in-length [stop-position(=) [fade-out-length]]
...
If the audio length can be determined from the input file header and any previous effects, then -0 (or, for historical reasons, 0) may be specified for stop-position to indicate the usual case of a fade-out that ends at the end of the input audio stream.
So to fade in 5 seconds, and fade out 7 seconds:
sox input.waw output.waw fade 5 -0 7
You can use a simple bash script, as this:
#! /bin/bash
WAV_IN=$1
WAV_OUT=$2
FADE_IN_L="0:5"
FADE_OUT_L="0:7"
LENGTH=`soxi -d $WAV_IN`
sox $WAV_IN $WAV_OUT fade $FADE_IN_L $LENGTH $FADE_OUT_L
soxi -d
returns the length of the wav file. See sox documentation for more on soxi.
You can run this bash script as follows:
./fadeWav test.wav faded.wav