SoX
Revision as of 19:17, 22 April 2009 by Michael Murtaugh (talk | contribs) (→Displaying information about an audio file)
sox (Sound Exchange) is a handy command line tool for generating, manipulating, and applying simple filters to audio.
Displaying information about an audio file
sox -V clap.wav -n
displays in my case...
sox: SoX v14.0.1
Input File : 'clap.wav'
Sample Size : 16-bit (2 bytes)
Sample Encoding: signed (2's complement)
Channels : 1
Sample Rate : 44100
Duration : 00:00.50 = 22050 samples = 37.5 CDDA sectors
Endian Type : little
Reverse Nibbles: no
Reverse Bits : no
Or use the "stat" effect:
sox clap.wav -e stat
displays
Samples read: 22050
Length (seconds): 0.500000
Scaled by: 2147483647.0
Maximum amplitude: 0.999969
Minimum amplitude: -0.999878
Midline amplitude: 0.000046
Mean norm: 0.015108
Mean amplitude: 0.000009
RMS amplitude: 0.047986
Maximum delta: 0.552368
Minimum delta: 0.000000
Mean delta: 0.005487
RMS delta: 0.017184
Rough frequency: 2513
Volume adjustment: 1.000
Generating tones or noise
sox -c1 -r8000 -n -t wav - synth 0.25 sine 220 vol 0.7 > beep.wav sox -c1 -r8000 -n -t wav - synth 0.25 sine 220-440 vol 0.7 > sweep_up.wav sox -c1 -r8000 -n -t wav - synth 0.25 sine 440-220 vol 0.7 > sweep_down.wav sox -c1 -r8000 -n -t wav - synth 0.25 noise vol 0.7 > ch.wav sox -c1 -r8000 -n -t wav - synth 2.0 sine 220-1000 vol 0.7 > sweep_up_long.wav sox -c1 -r8000 -n -t wav - synth 2.0 sine 1000-220 vol 0.7 > sweep_down_long.wav sox -c1 -r8000 -n -t wav - synth 0.5 square 330 vol 0.7 > bleep.wav
Working with "raw audio"
Working with raw files allows audio to get appended together; here sox is used to take a bunch of wavs, make them raw, send them all to stdout, the repackage them as a wav file.
(for file in *; do sox "$file" -t .raw -r 44100 -sw -c 2 -; done) | \
sox -t .raw -r 44100 -sw -c 2 - -t .wav newfile.wav
source: [1]