Sound eXchange


the Swiss Army knife of sound processing programs allows command line manipulation and generation of audio files.

Audio Analysis

Find out information about an audio file

sox -V orig.wav -e stat

Audio Synthesis

Produce a 3 second, 48kHz, audio file containing a sine-wave swept from 300 to 3300 Hz.

sox -n output.wav synth 3 sine 300-3300

Produce a constant 8KHz 3 second tone.

sox -r 8000 -n output.wav synth 3 sine 300-3300

Cascade two synth effects simultaneously, to create a more complex waveform:

play -n synth 0.5 sine 200-500 synth 0.5 sine fmod 700-100

Create a 1KHz Tone, 1/2 second long, very slightly attenuated

sox -n loud.wav synth 0.5 sin 1000 gain -1

Create a 1KHz Tone, 200msec long, significantly attenuated

sox -n quiet.wav synth 0.2 sin 1000 gain -20

Play the Digit "7" DTMF Tone for 0.5 seconds

play -n synth 0.5 sine 852 sine 1209 channels 1

Create a file of the Digit "7" DTMF Tone

sox -n 7.wav synth 0.5 sine 852 sine 1209 channels 1

Play a DTMF "Dial Tone" for 5 seconds

play -n synth 5 sine 350 sine 440 channels 1

Audio Manipulation

Play two wav files, one after the other, repeated 5 times

play loud.wav quiet3.wav repeat 5

Append one file to another file

sox file1.wav file2.wav outputfile.wav

Take a file and repeat it 20 times into an output file

sox input.wav longfile.wav repeat 20

Convert PCM file to a wav file

sox -t .ul -r 8000 -c 1 -b 8 -U  blah.PCMU -t wav -r 8000 -c 1 -b 8 -U  file.wav

Convert a two channel wav file to a single channel PCM file

For FREESWITCH moh files

  • Wave format is used for moh files
  • moh files needs to be converted to the codecs required:
    • pcma, pcmu
    • 8 bit Sample Size
    • 8000 kHz Sample Rate
    • 1 channel (mono)
    • files need to be named: moh_codec.wav
      • e.g. moh_pcmu.wav, moh_pcma.wav
    • files need to fit to the limited memory of the phones!

Convert wav file to PCMU file for use with freeswitch moh

sox -S -t wav -c 2 -2 -r 44100 orig.wav -t wav -c 1 -1 -r 8000 -U moh_pcmu.wav

Convert wave file to PCMA file for use with freeswitch moh

sox -S -t wav -c 2 -2 -r 44100 orig.wav -t wav -c 1 -1 -r 8000 -A moh_pcma.wav