SoX
Sound eXchange, abbreviated SoX, is a free digital audio editor which is licensed under the GPL and distributed by Chris Bagwell through SourceForge. SoX is written in standard C, with a command-line interface.
Contents
SoX scripts
Sample scripts included with SoX. Since SoX is developed mainly under Unix, these scripts are usually /bin/sh
scripts.
audiogen
- Generate audio using the "synth" effect.
crossfade.sh
- Crossfade two audio files.
crossfade_cat.sh
- Crossfade two audio files into a single file.
fmsim
- Make an audio file sound like its playing over an FM radio
startrec.sh
- Start recording audio after detecting non-silence.
testcd.sh
- Create audio files for a test cd. Useful for testing quality of audio equipment.
Usage
Note: For sox, version 12.18.1.
Usage: [ gopts ] [ fopts ] ifile [ fopts ] ofile [ effect [ effopts ] ]
- gopts
-
-e -h -p -q -S -V
- fopts
-
-r rate -c channels -s/-u/-U/-A/-a/-i/-g/-f -b/-w/-l/-d -v volume -x
- effect
-
avg band bandpass bandreject chorus compand copy dcshift deemph earwax echo echos fade filter flanger highp highpass lowp lowpass mask mcompand noiseprof noisered pan phaser pick pitch polyphase rate repeat resample reverb reverse silence speed stat stretch swap synth trim vibro vol
- effopts
- depends on effect
- Supported file formats
-
aiff al alsa au auto avr cdr cvs dat vms gsm hcom la lu maud mp3 nul ossdsp prc raw sb sf sl smp sndt sph 8svx sw txw ub ul uw voc vorbis vox wav wve
Example usage
The soxexam man pages recommend the following settings to compand the classical music work Also Sprach Zarathustra by Richard Strauss:
sox asz.aif aszc.aif compand 0.3,1 -90,-90,-70,-70,-60,-20,0,0 -5,0,0.2
Here's what this terminal command does. It first takes the asz.aif file and outputs it as aszc.aif, subjecting it to the compand filter. The soxexam man pages explain the settings as follows: "The transfer function ("-90,...") says that very soft sounds between -90 and -70 decibels (-90 is about the limit of 16-bit encoding) will remain unchanged. That keeps the compander from boosting the volume on "silent" passages such as between movements. However, sounds in the range -60 decibels to 0 decibels (maximum volume) will be boosted so that the 60-dB dynamic range of the original music will be compressed 3-to-1 into a 20-dB range, which is wide enough to enjoy the music but narrow enough to get around the road noise. The -5 dB output gain is needed to avoid clipping (the number is inexact, and was derived by experimentation). The 0 for the initial volume will work fine for a clip that starts with a bit of silence, and the delay of 0.2 has the effect of causing the compander to react a bit more quickly to sudden volume changes."
For a bunch of *.aif
files, as tcsh, enter:
foreach file (*.aif) sox $file $file.aif compand 0.4,1 -90,-90,-70,-70,-60,-30,0,0 -5,0,0.2 end wait
Miscellaneous examples
- Have Google Translate play back text:
wget -q -O- -U Mozilla "http://translate.google.com/translate_tts?q=hello+,+how+are+you?&tl=en-uk"|cvlc - |play -t wav - -t wav -t alsa
See also
- Ardour — a digital audio workstation.
- Sonic Visualiser — an application for viewing and analysing the contents of music audio files.