Cross fading several audio files using sox

a 夏天 提交于 2021-01-27 21:32:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!