sox
All SoX functionality is available using just the sox command. To simplify playing and recording audio, if SoX is invoked as play, the output file is automatically set to be the default sound device, and if invoked as rec, the default sound device is used as an input source. Additionally, the soxi command provides a convenient way to just query audio file header information.[1]
Documentation
- man 1 'sox' [EN]
Syntax
sox [PARAMETER ...] [INFILE ...] [PARAMETER ...] [OUTFILE ...] [PARAMETER ...]
Parameters
- Special Filenames
- The following special filenames may be used in certain circumstances in place of a normal filename on the command line:
- -n, --null
- This can be used in place of an input or output filename to specify that a 'null file' is to be used.
- NOTE:'null file' refers to a SoX-specific mechanism and is not related to any operating-system mechanism with a similar name.
- -p, --sox-pipe
- This can be used in place of an output filename to specify that the SoX command should be used as in input pipe to another SoX command.
- Global Options
- These options can be specified on the command line at any point before the first effect name.
- --combine concatenate|merge|mix|mix−power|multiply|sequence
- Select the input file combining method; for some of these, short options are available: -m selects 'mix', -M selects 'merge', and -T selects 'multiply'.
- -m, -M
- Equivalent to --combine mix and --combine merge, respectively.
- -v FACTOR, --volume FACTOR
- Intended for use when combining multiple input files, this option adjusts the volume of the file that follows it on the command line by a factor of FACTOR.
- Input & Output File Format Options
- These options apply to the input or output file whose name they immediately precede on the command line and are used mainly when working with headerless file formats or when specifying a format for the output file that is different to that of the input file.
- -c CHANNELS, --channels CHANNELS
- The number of audio channels in the audio file. This can be any number greater than zero.
- -r RATE, --rate RATE
- Gives the sample rate in Hz (or kHz if appended with 'k') of the file.
- Effects
- In addition to converting, playing and recording audio files, SoX can be used to invoke a number of audio 'effects'. Multiple effects may be applied by specifying them one after another at the end of the SoX command line.
- trim POSITION
- Cuts portions out of the audio. Any number of positions may be given; audio is not sent to the output until the first position is reached. The effect then alternates between copying and discarding audio at each position.
Examples
- Create an empty 10 seconds long WAVE file
sox --null --rate 44100 --channels 2 'empty.wav' trim 0.0 10.0
- Mix to files together
sox -m 'music.mp3' 'voice.wav' 'mixed.wav'
References
- ↑ man 1 'sox'