4253 lines · 146.1 KB · Text
RawDownload
'\" t'\" The line above instructs most `man' programs to invoke tbl'\"'\" Separate paragraphs; not the same as PP which resets indent level..de SP.if t .sp .5.if n .sp..'\"'\" Replacement em-dash for nroff (default is too short)..ie n .ds m " - .el .ds m \(em'\"'\" Placeholder macro for if longer nroff arrow is needed..ds RA \(->'\"'\" Decimal point set slightly raised.if t .ds d \v'-.15m'.\v'+.15m'.if n .ds d .'\"'\" Enclosure macro for examples.de EX.SP.nf.ft CW...de EE.ft R.SP.fi...TH SoX 1 "December 31, 2014" "sox" "Sound eXchange".SH NAMESoX \- Sound eXchange, the Swiss Army knife of audio manipulation.SH SYNOPSIS.nf\fBsox\fR [\fIglobal-options\fR] [\fIformat-options\fR] \fIinfile1\fR	[[\fIformat-options\fR] \fIinfile2\fR] ... [\fIformat-options\fR] \fIoutfile\fR	[\fIeffect\fR [\fIeffect-options\fR]] ....SP\fBplay\fR [\fIglobal-options\fR] [\fIformat-options\fR] \fIinfile1\fR	[[\fIformat-options\fR] \fIinfile2\fR] ... [\fIformat-options\fR]	[\fIeffect\fR [\fIeffect-options\fR]] ....SP\fBrec\fR [\fIglobal-options\fR] [\fIformat-options\fR] \fIoutfile\fR	[\fIeffect\fR [\fIeffect-options\fR]] ....fi.SH DESCRIPTION.SS IntroductionSoX reads and writes audio files in most popular formats and canoptionally apply effects to them. It can combine multiple inputsources, synthesise audio, and, on many systems, act as a generalpurpose audio player or a multi-track audio recorder. It also haslimited ability to split the input into multiple output files..SPAll SoX functionality is available using just the \fBsox\fR command.To simplify playing and recording audio, if SoX is invoked as\fBplay\fR, the output file is automatically set to be the default sounddevice, and if invoked as \fBrec\fR, the default sound device is used as aninput source.Additionally, the.BR soxi (1)command provides a convenient way to just query audio file header information..SPThe heart of SoX is a library called libSoX.  Those interested inextending SoX or using it in other programs should refer to the libSoXmanual page:.BR libsox (3)..SPSoX is a command-line audio processing tool, particularly suited to makingquick, simple edits and to batch processing.If you need an interactive, graphical audio editor, use.BR audacity (1)..TScenter;c8 c8 c.*	*	*.TE.DT.SPThe overall SoX processing chain can be summarised as follows:.TScenter;l.Input(s) \*(RA Combiner \*(RA Effects \*(RA Output(s).TE.DT.SPNote however, that on the SoX command line, the positions of theOutput(s) and the Effects are swapped w.r.t. the logical flow justshown.  Note also that whilst options pertaining to files are placedbefore their respective file name, the opposite is true for effects.To show how this works in practice, here is a selection of examples ofhow SoX might be used.  The simple.EX   sox recital.au recital.wav.EEtranslates an audio file in Sun AU format to a Microsoft WAV file, whilst.EX   sox recital.au \-b 16 recital.wav channels 1 rate 16k fade 3 norm.EEperforms the same format translation, but also applies four effects(down-mix to one channel, sample rate change, fade-in, nomalize),and stores the result at a bit-depth of 16..EX   sox \-r 16k \-e signed \-b 8 \-c 1 voice-memo.raw voice-memo.wav.EEconverts `raw' (a.k.a. `headerless') audio to a self-describing file format,.EX   sox slow.aiff fixed.aiff speed 1.027.EEadjusts audio speed,.EX   sox short.wav long.wav longer.wav.EEconcatenates two audio files, and.EX   sox \-m music.mp3 voice.wav mixed.flac.EEmixes together two audio files..EX   play \(dqThe Moonbeams/Greatest/*.ogg\(dq bass +3.EEplays a collection of audio files whilst applying a bass boosting effect,.EX   play \-n \-c1 synth sin %\-12 sin %\-9 sin %\-5 sin %\-2 fade h 0.1 1 0.1.EEplays a synthesised `A minor seventh' chord with a pipe-organ sound,.EX   rec \-c 2 radio.aiff trim 0 30:00.EErecords half an hour of stereo audio, and.EX   play \-q take1.aiff & rec \-M take1.aiff take1\-dub.aiff.EE(with POSIX shell and where supported by hardware)records a new track in a multi-track recording.  Finally,.EX.ne 3   rec \-r 44100 \-b 16 \-e signed-integer \-p \\	silence 1 0.50 0.1% 1 10:00 0.1% | \\	sox \-p song.ogg silence 1 0.50 0.1% 1 2.0 0.1% : \\	newfile : restart.EErecords a stream of audio such as LP/cassette and splits in to multipleaudio files at points with 2 seconds of silence.  Also, it does not startrecording until it detects audio is playing and stops after it sees10 minutes of silence..SPN.B.  The above is just an overview of SoX's capabilities; detailedexplanations of how to use \fIall\fR SoX parameters, file formats, andeffects can be found below in this manual, in.BR soxformat (7),and in.BR soxi (1)..SS File Format TypesSoX can work with `self-describing' and `raw' audio files.`self-describing' formats (e.g. WAV, FLAC, MP3) have a header thatcompletely describes the signal and encoding attributes of the audiodata that follows. `raw' or `headerless' formats do not contain thisinformation, so the audio characteristics of these must be describedon the SoX command line or inferred from those of the input file..SPThe following four characteristics are used to describe the format ofaudio data such that it can be processed with SoX:.TPsample rateThe sample rate in samples per second (`Hertz' or `Hz').Digital telephony traditionally uses a sample rate of 8000\ Hz (8\ kHz),though these days, 16 and even 32\ kHz are becoming more common. AudioCompact Discs use 44100\ Hz (44\*d1\ kHz). Digital Audio Tape and manycomputer systems use 48\ kHz. Professional audio systems often use 96kHz..TPsample sizeThe number of bits used to store each sample.  Today, 16-bit iscommonly used. 8-bit was popular in the early days of computeraudio. 24-bit is used in the professional audio arena. Other sizes arealso used..TPdata encodingThe way in which each audio sample is represented (or `encoded').  Someencodings have variants with different byte-orderings or bit-orderings.Some compress the audio data so that the stored audio data takes up lessspace (i.e. disk space or transmission bandwidth) than the other formatparameters and the number of samples would imply.  Commonly-usedencoding types include floating-point, \(*m-law, ADPCM, signed-integerPCM, MP3, and FLAC..TPchannelsThe number of audio channels contained in the file.  One (`mono') andtwo (`stereo') are widely used.  `Surround sound' audio typicallycontains six or more channels..PPThe term `bit-rate' is a measure of the amount of storage occupied by anencoded audio signal over a unit of time.  It can depend on all of theabove and is typically denoted as a number of kilo-bits per second(kbps).  An A-law telephony signal has a bit-rate of 64 kbps. MP3-encodedstereo music typically has a bit-rate of 128\-196 kbps. FLAC-encodedstereo music typically has a bit-rate of 550\-760 kbps..SPMost self-describing formats also allow textual `comments' to beembedded in the file that can be used to describe the audio in some way,e.g. for music, the title, the author, etc..SPOne important use of audio file comments is to convey `Replay Gain'information.  SoX supports applying Replay Gain information (for certaininput file formats only; currently, at least FLAC and Ogg Vorbis), but notgenerating it.  Note that by default, SoX copies input file commentsto output files that support comments, so output files may containReplay Gain information if some was present in the input file.  In thiscase, if anything other than a simple format conversion was performedthen the output file Replay Gain information is likely to be incorrectand so should be recalculated using a tool that supports this (not SoX)..SPThe.BR soxi (1)command can be used to display information from audio file headers..SS Determining & Setting The File FormatThere are several mechanisms available for SoX to use to determine or set theformat characteristics of an audio file.  Depending on the circumstances,individual characteristics may be determined or set using different mechanisms..SPTo determine the format of an input file, SoX will use, in order ofprecedence and as given or available:.IP 1. 4Command-line format options..IP 2. 4The contents of the file header..IP 3. 4The filename extension..PPTo set the output file format, SoX will use, in order ofprecedence and as given or available:.IP 1. 4Command-line format options..IP 2. 4The filename extension..IP 3. 4The input file format characteristics, or the closestthat is supported by the output file type..PPFor all files, SoX will exit with an errorif the file type cannot be determined. Command-line format options mayneed to be added or changed to resolve the problem..SS Playing & Recording AudioThe.B playand.B reccommands are provided so that basic playing andrecording is as simple as.EX   play existing-file.wav.EEand.EX   rec new-file.wav.EEThese two commands are functionally equivalent to.EX   sox existing-file.wav \-d.EEand.EX   sox \-d new-file.wav.EEOf course, further options and effects (as described below) can beadded to the commands in either form..TScenter;c8 c8 c.*	*	*.TE.DT.SPSome systems provide more than one type of (SoX-compatible) audiodriver, e.g. ALSA & OSS, or SUNAU & AO.Systems can also have more than one audio device (a.k.a. `sound card').If more than one audio driver has beenbuilt-in to SoX, and the default selected by SoX when recording or playingis not the one that is wanted, then the.B AUDIODRIVERenvironment variable can be used to override the default.  For example(on many systems):.EX   set AUDIODRIVER=oss   play ....EEThe.B AUDIODEVenvironment variable can be used to override the default audio device,e.g..EX   set AUDIODEV=/dev/dsp2   play ...   sox ... \-t oss.EEor.EX   set AUDIODEV=hw:soundwave,1,2   play ...   sox ... \-t alsa.EENote that the way of setting environment variables varies from systemto system\*mfor some specific examples, see `SOX_OPTS' below..SPWhen playing a file with a sample rate that is not supported by theaudio output device, SoX will automatically invoke the \fBrate\fR effectto perform the necessary sample rate conversion.  Forcompatibility with old hardware, thedefault \fBrate\fR quality level is set to `low'. Thiscan be changed by explicitly specifying the \fBrate\fReffect with a different quality level, e.g..EX   play ... rate \-m.EEor by using the.B \-\-play\-rate\-argoption (see below)..TScenter;c8 c8 c.*	*	*.TE.DT.SPTo help with setting a suitable recording level, SoX includes a peak-levelmeter which can be invoked (before making the actual recording) as follows:.EX   rec \-n.EEThe recording level should be adjusted (using the system-provided mixerprogram, not SoX) so that the meter is \fIat most occasionally\fR fullscale, and never `in the red' (an exclamation mark is shown).See also \fB\-S\fR below..SS AccuracyMany file formats that compress audio discard some of the audio signalinformation whilst doing so. Converting to such a format and then convertingback again will not produce an exact copy of the original audio.  Thisis the case for many formats used in telephony (e.g. A-law, GSM) wherelow signal bandwidth is more important than high audio fidelity, and formany formats used in portable music players (e.g. MP3, Vorbis) whereadequate fidelity can be retained even with the large compression ratiosthat are needed to make portable players practical..SPFormats that discard audio signal information are called `lossy'.Formats that do not are called `lossless'.  The term `quality' is used as ameasure of how closely the original audio signal can be reproduced whenusing a lossy format..SPAudio file conversion with SoX is lossless when it can be, i.e. when notusing lossy compression, when not reducing the sampling rate or numberof channels, and when the number of bits used in the destination formatis not less than in the source format.  E.g.  converting from an 8-bitPCM format to a 16-bit PCM format is lossless but converting from an8-bit PCM format to (8-bit) A-law isn't..SP.B N.B.SoX converts all audio files to an internal uncompressedformat before performing any audio processing. This means thatmanipulating a file that is stored in a lossy format can cause furtherlosses in audio fidelity.  E.g. with.EX   sox long.mp3 short.mp3 trim 10.EESoX first decompresses the input MP3 file, then applies the.B trimeffect, and finally creates the output MP3 file by re-compressing theaudio\*mwith a possible reduction in fidelity above that whichoccurred when the input file was created.Hence, if what is ultimately desired is lossily compressed audio, it ishighly recommended to perform all audio processing using lossless fileformats and then convert to the lossy format only at the final stage..SP.B N.B.Applying multiple effects with a single SoX invocation will,in general, produce more accurate results than those produced usingmultiple SoX invocations..SS DitheringDithering is a technique used to maximise the dynamic range of audiostored at a particular bit-depth. Any distortion introduced byquantisation is decorrelated by adding a small amount of white noiseto the signal.  In most cases, SoX can determine whether the selectedprocessing requires dither and will add it during output formatting ifappropriate..SPSpecifically, by default, SoX automatically adds TPDF ditherwhen the output bit-depth is less than 24 and anyof the following are true:.IP \(bu 4bit-depth reduction has been specified explicitly using a command-lineoption.IP \(bu 4the output file format supports only bit-depths lower than that of theinput file format.IP \(bu 4an effect has increased effective bit-depth within the internalprocessing chain.PPFor example, adjusting volume with.B vol 0.25requires two additional bits in which to losslessly store its results(since 0\*d25 decimal equals 0\*d01 binary).  So if the input filebit-depth is 16, then SoX's internal representation will utilise 18bits after processing this volume change.  In order to store theoutput at the same depth as the input, dithering is used to remove theadditional bits..SPUse the.B \-Voption to see what processing SoX has automatically added. The.B \-Doption may be given to override automatic dithering.  To invokedithering manually (e.g. to select a noise-shaping curve), see the.B dithereffect..SS ClippingClipping is distortion that occurs when an audio signal level (or`volume') exceeds the range of the chosen representation.  In mostcases, clipping is undesirable and so should be corrected by adjustingthe level prior to the point (in the processing chain) at which itoccurs..SPIn SoX, clipping could occur, as you might expect, when using the.B volor.B gaineffects to increase the audio volume. Clipping could also occur with manyother effects, when converting one format to another, and even whensimply playing the audio..SPPlaying an audio file often involves resampling, and processing byanalogue components can introduce a small DC offset and/oramplification, all of which can produce distortion if the audio signallevel was initially too close to the clipping point..SPFor these reasons, it is usual to make sure that an audiofile's signal level has some `headroom', i.e. it does not exceed a particularlevel below the maximum possible level for the given representation.Some standards bodies recommend as much as 9dB headroom, but in most cases,3dB (\(~~ 70% linear) is enough.  Note that this wisdomseems to have been lost in modern music production; in fact, many CDs,MP3s, etc.  are now mastered at levels \fIabove\fR 0dBFS i.e. theaudio is clipped as delivered..SPSoX's.B statand.B statseffects can assist in determining the signal level in an audio file. The.B gainor.B voleffect can be used to prevent clipping, e.g..EX   sox dull.wav bright.wav gain \-6 treble +6.EEguarantees that the treble boost will not clip..SPIf clipping occurs at any point during processing,SoX will display a warning message to that effect..SPSee also.B \-Gand the.B gainand.B normeffects..SS Input File CombiningSoX's input combiner can be configured (see OPTIONS below) tocombine multiple files using any of thefollowing methods: `concatenate', `sequence', `mix', `mix-power',`merge', or `multiply'.The default method is `sequence' for.BR play ,and `concatenate' for.B recand.BR sox ..SPFor all methods other than `sequence', multiple input files must havethe same sampling rate. If necessary, separate SoX invocations can beused to make sampling rate adjustments prior to combining..SPIf the `concatenate' combining method is selected (usually, this will beby default) then the input files must also have the same number ofchannels.  The audio from each input will be concatenated in the ordergiven to form the output file..SPThe `sequence' combining method is selected automatically for.BR play .It is similar to `concatenate' in that the audio from each input file issent serially to the output file. However, here the output file may beclosed and reopened at the corresponding transition between inputfiles. This may be just what is needed when sending different types ofaudio to an output device, but is not generally useful when the output is anormal file..SP

Lines 1–500 of 4253.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t