Home > Software design >  SoX batch convert adding white noise
SoX batch convert adding white noise

Time:05-22

I'm trying to add white noise to hundreds of files. I find a command but don't know how to adapt it. There is a source folder with files and an empty destination folder. Could someone help me with the right command? I'm using OSX.

http://linguistics.berkeley.edu/plab/guestwiki/index.php?title=Sox_in_phonetic_research#Add_noise_to_an_audio_file

CodePudding user response:

You should put the command in a for loop, then refer to the for variable as file name.

I assume that the source folder and the destination folder are on the same level.

for file in *.wav; do sox "$file" -p synth whitenoise vol 0.02 | sox -m "$file" - "../DESTINATION/$file"; done

In addition, if you want to use a suffix in the name of the output files, use basename to exclude the extension:

for file in *.wav; do sox "$file" -p synth whitenoise vol 0.02 | sox -m "$file" - "../DESTINATION/$(basename $file)_output.wav"; done
  • Related