I'm trying to create a fade in and fade out for several wave files that I won't know the total time duration in seconds of. I read the manual but the example I see all looks like I need to know the full length of the file. Can someone post an example of fading in 5 seconds and fading out 7 seconds without knowing the full length of the wav file?
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With