SoX - Sound eXchange, the Swiss Army knife of audio manipulation.
SoX reads and writes audio files in most popular formats and can optionally apply effects to them; it can combine multiple input sources, synthesise audio, and, on many systems, act as a general purpose audio player or a multi-track audio recorder.
Few things that can be done with this knife:
The overall SoX processing chain can be summarized as follows:
Input(s) → Balancing → Combiner → Effects → Output
Basic Examples:
# Translate an audio file in Sun AU format to a Microsoft WAV file
sox recital.au recital.wav
# Format translation with rate/size changes, down-mix to mono, apply effects
sox recital.au -r 12000 -1 -c 1 recital.wav vol 0.7 dither
# Add a header to a raw audio file
sox -r 8000 -u -1 -c 1 voice-memo.raw voice-memo.wav
# Adjust audio speed using the most accurate rabbit algorithm
sox slow.aiff fixed.aiff speed 1.027 rabbit -c0
# Concatenate two audio files
sox short.au long.au longer.au
# Mix together two audio files
sox -m music.mp3 voice.wav mixed.flac
# Play a collection of audio files with bass boosting
play "The Moonbeams/Greatest/*.ogg" bass +3
# Play a synthesised 'A minor seventh' chord with a pipe-organ sound
play -n -c1 synth sin %-12 sin %-9 sin %-5 sin %-2 fade q 0.1 1 0.1
# Record 10 seconds of stereo audio
rec -c 2 test.aiff trim 0 10
# Record a new track in a multi-track recording
rec -M take1.aiff take1-dub.aiff
ECHO Effect:
# Sound like doubling the number of instruments
play file.xxx echo 0.8 0.88 60 0.4
# Metallic robot playing music
play file.xxx echo 0.8 0.88 6 0.4
# Open air concert in the mountains
play file.xxx echo 0.8 0.9 1000 0.3
# One mountain more
play file.xxx echo 0.8 0.9 1000 0.3 1800 0.25
ECHOS Effect:
# Bounced twice in symmetric echos
play file.xxx echos 0.8 0.7 700 0.25 700 0.3
# Bounced twice in asymmetric echos
play file.xxx echos 0.8 0.7 700 0.25 900 0.3
# Sounds like played in a garage
play file.xxx echos 0.8 0.7 40 0.25 63 0.3
CHORUS Effect:
# Single delay - more overloaded
play file.xxx chorus 0.7 0.9 55 0.4 0.25 2 -t
# Two delays
play file.xxx chorus 0.6 0.9 50 0.4 0.25 2 -t 60 0.32 0.4 1.3 -s
# Big chorus (three additional samples)
play file.xxx chorus 0.5 0.9 50 0.4 0.25 2 -t 60 0.32 0.4 2.3 -t 40 0.3 0.3 1.3 -s
FLANGER Effect:
# Groove the sample
play file.xxx flanger
# Triangular modulation
play file.xxx flanger triangle
REVERB Effect:
# Default reverberance (50%)
play file.xxx reverb
# 80% reverberance
play file.xxx reverb 80
PHASER Effect:
play file.xxx phaser 0.8 0.74 3 0.4 0.5 -t
# Drunken loudspeaker system
play file.xxx phaser 0.9 0.85 4 0.23 1.3 -s
# Popular sound
play file.xxx phaser 0.89 0.85 1 0.24 2 -t
# Ten springs in your ears
play file.xxx phaser 0.6 0.66 3 0.6 2 -t
Speed and Pitch:
# Play at half the speed (preserving pitch)
play file.wav stretch 2
# Play at twice the speed
play file.wav stretch 0.5
# Speed up (Mickey Mouse voices)
play file.wav speed 2
# Raise pitch by 1 whole note (100 cents)
play file.wav pitch 100
Reducing Noise:
# First, create a noise profile from a silent period
sox file.wav -n trim 0 1.5 noiseprof /tmp/profile
# Then reduce noise using the profile
play file.wav noisered /tmp/profile
Recording:
rec parameters filename other-effects silence 1 5 2%
Thanks to Juergen Mueller et.al, for making such a great tool.
About Hemanth HM
Hemanth HM is a Sr. Machine Learning Manager at PayPal, Google Developer Expert, TC39 delegate, FOSS advocate, and community leader with a passion for programming, AI, and open-source contributions.