sox
Convert, edit, and play audio files
TLDR
Merge two audio files into one
Trim an audio file to the specified times
Normalize an audio file (adjust volume to the maximum peak level, without clipping)
Reverse and save an audio file
Print statistical data of an audio file
Increase the volume of an audio file by 2x
SYNOPSIS
sox [global options] infile [infile ...] [format options] outfile [effect [effect options] ...]
To play audio:
sox [global options] infile [infile ...] -d | --play [effect [effect options] ...]
To record audio:
sox [global options] -d | --record [format options] outfile [effect [effect options] ...]
infile and outfile can be paths to audio files, or special names like - (standard input/output), /dev/null, or device drivers.
PARAMETERS
-h, --help
Displays the help message with a list of options and effects.
-V, --version
Shows the version information of SoX.
-D, --no-dither
Disables dithering during sample rate or bit-depth conversions.
-q, --no-show-progress
Suppresses the display of the processing progress bar.
-S, --show-progress
Forces the display of the processing progress bar, even in quiet mode.
-v
Adjusts the input volume by a given factor (e.g., 0.5 for half, 2.0 for double). Can also be a percentage or dB value.
-r
Sets the sample rate for the input or output file (e.g., 44100, 48000).
-c
Sets the number of audio channels (e.g., 1 for mono, 2 for stereo).
-b
Sets the number of bits per sample (e.g., 8, 16, 24, 32).
-t
Explicitly specifies the audio file type or driver to use (e.g., wav, mp3, flac, alsa).
-d, --default-device
Special input/output pseudo-file name to use the default audio playback/recording device (for --play or --record).
--input-buffer
Sets the input buffer size, useful for streaming or slow devices.
fade
Adds a fade-in and/or fade-out effect to the audio. type can be 'h' (half-sine), 'q' (quarter-sine), 't' (triangular), etc.
norm [
Normalizes the audio to a given peak level (default -3dB). Helps achieve a consistent volume level throughout the audio.
trim
Trims audio, removing parts before start and/or after start + length.
reverse
Reverses the audio samples, playing the audio backward.
speed
Changes the audio speed (and pitch) by a given factor (e.g., 1.5 for 150% speed). For pitch change without tempo, use the 'pitch' effect.
pitch
Changes the pitch of the audio by a given number of semitones without affecting its tempo.
DESCRIPTION
SoX, short for Sound eXchange, is a powerful and versatile command-line utility for digital audio processing. It can convert audio files between various popular formats, apply a wide range of audio effects, and even play or record audio directly from your system's sound devices. Often referred to as "the Swiss Army knife of sound processing," SoX supports an extensive list of file formats (e.g., WAV, MP3, FLAC, OGG, AIFF) and codecs. It's widely used in scripting for batch conversions, sound design, cleaning up audio, and preparing audio for web or video applications. Its robust feature set and cross-platform availability make it an indispensable tool for audio enthusiasts, developers, and system administrators working with audio files.
CAVEATS
SoX can be quite resource-intensive for large files or complex effect chains. While highly versatile, its command-line interface can be complex for new users due to the multitude of options and effect parameters. Users may need to install additional libraries (like libmp3lame for MP3 encoding or libflac for FLAC) for full format support, depending on their distribution's default SoX package. It is primarily a batch processing tool and less suited for very low-latency real-time audio applications.
EXTENSIVE FORMAT SUPPORT
SoX supports an impressive array of audio file formats, including common ones like WAV, MP3, FLAC, OGG, AIFF, AU, and many more obscure or legacy types. This makes it an ideal tool for interoperability between different audio systems or software.
CHAINING EFFECTS
One of SoX's powerful features is the ability to chain multiple audio effects together in a single command. Effects are applied sequentially from left to right, allowing for complex audio transformations with a single invocation. For example, `sox input.wav output.mp3 trim 10 5 norm reverse` will trim, normalize, and then reverse 5 seconds of audio starting at the 10-second mark.
HISTORY
SoX development began in 1991, originally created by Lance Norskog. It quickly gained popularity as a robust and open-source solution for audio file format conversion on Unix-like systems. Over the decades, it has been continuously maintained and expanded by a dedicated community, adding a vast array of audio effects and support for numerous modern and legacy audio formats. Its longevity and consistent development have cemented its place as a cornerstone utility in the Linux and open-source audio ecosystem.