Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross fading several audio files using sox

I'm trying to cross-fade several audio files together with a 3 second cross-fade and join them together in to one file with sox.

I can join several files together by the command below but not sure how to cross fade between each one:

sox $(ls /tmp/a*.wav | sort -n) /tmp/out/out.wav

I can cross fade two files with the commands below but not sure how to combine the first line that joins several files together with the second line that splices / cross fades

sox 100hz.wav 440hz.wav out.wav splice $(soxi -D 100hz.wav),3

I found this question but the answer doesn't work for me. crossfading a group of audio files with sox splice

like image 227
Rick T Avatar asked Dec 05 '25 14:12

Rick T


1 Answers

I don't know if you are aware of the crossfade_cat.sh script offered by sox. You could just use it successively:

./crossfade_cat.sh 1 440.wav 660.wav auto auto && ./crossfade_cat.sh 1 mix.wav 880.wav auto auto

Or if you want to crossfade a high number of wav files, to use all files in a directory you could use a shell loop, something like this:

crossfade_dur=1
i=0

for file in *.wav
do

    i=$((i+1))

    if [ $i -eq 1 ]
    then
        cp $file mix.wav
    else
        crossfade_cat.sh $crossfade_dur mix.wav $file auto auto
    fi

done
like image 111
Frank Zalkow Avatar answered Dec 07 '25 08:12

Frank Zalkow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!