问题
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
回答1:
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
来源:https://stackoverflow.com/questions/28652490/cross-fading-several-audio-files-using-sox