README.osx wasn't easily readable in Finder. Revert back to
[sox.git] / sox.1
blob4d3253567255cd5dd769103e5b90a8e166501a94
1 '\" t
2 '\" The line above instructs most `man' programs to invoke tbl
3 '\"
4 '\" Separate paragraphs; not the same as PP which resets indent level.
5 .de SP
6 .if t .sp .5
7 .if n .sp
8 ..
9 '\"
10 '\" Replacement em-dash for nroff (default is too short).
11 .ie n .ds m " - 
12 .el .ds m \(em
13 '\"
14 '\" Placeholder macro for if longer nroff arrow is needed.
15 .ds RA \(->
16 '\"
17 '\" Decimal point set slightly raised
18 .if t .ds d \v'-.15m'.\v'+.15m'
19 .if n .ds d .
20 '\"
21 '\" Enclosure macro for examples
22 .de EX
23 .SP
24 .nf
25 .ft CW
27 .de EE
28 .ft R
29 .SP
30 .fi
32 .TH SoX 1 "February 19, 2011" "sox" "Sound eXchange"
33 .SH NAME
34 SoX \- Sound eXchange, the Swiss Army knife of audio manipulation
35 .SH SYNOPSIS
36 .nf
37 \fBsox\fR [\fIglobal-options\fR] [\fIformat-options\fR] \fIinfile1\fR
38         [[\fIformat-options\fR] \fIinfile2\fR] ... [\fIformat-options\fR] \fIoutfile\fR
39         [\fIeffect\fR [\fIeffect-options\fR]] ...
40 .SP
41 \fBplay\fR [\fIglobal-options\fR] [\fIformat-options\fR] \fIinfile1\fR
42         [[\fIformat-options\fR] \fIinfile2\fR] ... [\fIformat-options\fR]
43         [\fIeffect\fR [\fIeffect-options\fR]] ...
44 .SP
45 \fBrec\fR [\fIglobal-options\fR] [\fIformat-options\fR] \fIoutfile\fR
46         [\fIeffect\fR [\fIeffect-options\fR]] ...
47 .fi
48 .SH DESCRIPTION
49 .SS Introduction
50 SoX reads and writes audio files in most popular formats and can
51 optionally apply effects to them. It can combine multiple input
52 sources, synthesise audio, and, on many systems, act as a general
53 purpose audio player or a multi-track audio recorder. It also has
54 limited ability to split the input into multiple output files.
55 .SP
56 All SoX functionality is available using just the \fBsox\fR command.
57 To simplify playing and recording audio, if SoX is invoked as
58 \fBplay\fR, the output file is automatically set to be the default sound
59 device, and if invoked as \fBrec\fR, the default sound device is used as an
60 input source.
61 Additionally, the
62 .BR soxi (1)
63 command provides a convenient way to just query audio file header information.
64 .SP
65 The heart of SoX is a library called libSoX.  Those interested in
66 extending SoX or using it in other programs should refer to the libSoX
67 manual page:
68 .BR libsox (3).
69 .SP
70 SoX is a command-line audio processing tool, particularly suited to making
71 quick, simple edits and to batch processing.
72 If you need an interactive, graphical audio editor, use
73 .BR audacity (1).
74 .TS
75 center;
76 c8 c8 c.
77 *       *       *
78 .TE
79 .DT
80 .SP
81 The overall SoX processing chain can be summarised as follows:
82 .TS
83 center;
85 Input(s) \*(RA Combiner \*(RA Effects \*(RA Output(s)
86 .TE
87 .DT
88 .SP
89 Note however, that on the SoX command line, the positions of the
90 Output(s) and the Effects are swapped w.r.t. the logical flow just
91 shown.  Note also that whilst options pertaining to files are placed
92 before their respective file name, the opposite is true for effects.
93 To show how this works in practice, here is a selection of examples of
94 how SoX might be used.  The simple
95 .EX
96    sox recital.au recital.wav
97 .EE
98 translates an audio file in Sun AU format to a Microsoft WAV file, whilst
99 .EX
100    sox recital.au \-b 16 recital.wav channels 1 rate 16k fade 3 norm
102 performs the same format translation, but also applies four effects
103 (down-mix to one channel, sample rate change, fade-in, nomalize),
104 and stores the result at a bit-depth of 16.
106    sox \-r 16k \-e signed \-b 8 \-c 1 voice-memo.raw voice-memo.wav
108 converts `raw' (a.k.a. `headerless') audio to a self-describing file format,
110    sox slow.aiff fixed.aiff speed 1.027
112 adjusts audio speed,
114    sox short.wav long.wav longer.wav
116 concatenates two audio files, and
118    sox \-m music.mp3 voice.wav mixed.flac
120 mixes together two audio files.
122    play \(dqThe Moonbeams/Greatest/*.ogg\(dq bass +3
124 plays a collection of audio files whilst applying a bass boosting effect,
126    play \-n \-c1 synth sin %\-12 sin %\-9 sin %\-5 sin %\-2 fade h 0.1 1 0.1
128 plays a synthesised `A minor seventh' chord with a pipe-organ sound,
130    rec \-c 2 radio.aiff trim 0 30:00
132 records half an hour of stereo audio, and
134    play \-q take1.aiff & rec \-M take1.aiff take1-dub.aiff
136 (with POSIX shell and where supported by hardware)
137 records a new track in a multi-track recording.  Finally,
139 .ne 3
140    rec \-r 44100 \-b 16 \-s \-p silence 1 0.50 0.1% 1 10:00 0.1% | \\
141         sox \-p song.ogg silence 1 0.50 0.1% 1 2.0 0.1% : \\
142         newfile : restart
144 records a stream of audio such as LP/cassette and splits in to multiple
145 audio files at points with 2 seconds of silence.  Also, it does not start
146 recording until it detects audio is playing and stops after it sees
147 10 minutes of silence.
149 N.B.  The above is just an overview of SoX's capabilities; detailed
150 explanations of how to use \fIall\fR SoX parameters, file formats, and
151 effects can be found below in this manual, in
152 .BR soxformat (7),
153 and in
154 .BR soxi (1).
155 .SS File Format Types
156 SoX can work with `self-describing' and `raw' audio files.
157 `self-describing' formats (e.g. WAV, FLAC, MP3) have a header that
158 completely describes the signal and encoding attributes of the audio
159 data that follows. `raw' or `headerless' formats do not contain this
160 information, so the audio characteristics of these must be described
161 on the SoX command line or inferred from those of the input file.
163 The following four characteristics are used to describe the format of
164 audio data such that it can be processed with SoX:
166 sample rate
167 The sample rate in samples per second (`Hertz' or `Hz').
168 Digital telephony traditionally uses a sample rate of 8000\ Hz (8\ kHz),
169 though these days, 16 and even 32\ kHz are becoming more common. Audio
170 Compact Discs use 44100\ Hz (44\*d1\ kHz). Digital Audio Tape and many
171 computer systems use 48\ kHz. Professional audio systems often use 96
172 kHz.
174 sample size
175 The number of bits used to store each sample.  Today, 16-bit is
176 commonly used. 8-bit was popular in the early days of computer
177 audio. 24-bit is used in the professional audio arena. Other sizes are
178 also used.
180 data encoding
181 The way in which each audio sample is represented (or `encoded').  Some
182 encodings have variants with different byte-orderings or bit-orderings.
183 Some compress the audio data so that the stored audio data takes up less
184 space (i.e. disk space or transmission bandwidth) than the other format
185 parameters and the number of samples would imply.  Commonly-used
186 encoding types include floating-point, \(*m-law, ADPCM, signed-integer
187 PCM, MP3, and FLAC.
189 channels
190 The number of audio channels contained in the file.  One (`mono') and
191 two (`stereo') are widely used.  `Surround sound' audio typically
192 contains six or more channels.
194 The term `bit-rate' is a measure of the amount of storage occupied by an
195 encoded audio signal over a unit of time.  It can depend on all of the
196 above and is typically denoted as a number of kilo-bits per second
197 (kbps).  An A-law telephony signal has a bit-rate of 64 kbs. MP3-encoded
198 stereo music typically has a bit-rate of 128\-196 kbps. FLAC-encoded
199 stereo music typically has a bit-rate of 550\-760 kbps.
201 Most self-describing formats also allow textual `comments' to be
202 embedded in the file that can be used to describe the audio in some way,
203 e.g. for music, the title, the author, etc.
205 One important use of audio file comments is to convey `Replay Gain'
206 information.  SoX supports applying Replay Gain information, but not
207 generating it.  Note that by default, SoX copies input file comments
208 to output files that support comments, so output files may contain
209 Replay Gain information if some was present in the input file.  In this
210 case, if anything other than a simple format conversion was performed
211 then the output file Replay Gain information is likely to be incorrect
212 and so should be recalculated using a tool that supports this (not SoX).
215 .BR soxi (1)
216 command can be used to display information from audio file headers.
217 .SS Determining & Setting The File Format
218 There are several mechanisms available for SoX to use to determine or set the
219 format characteristics of an audio file.  Depending on the circumstances,
220 individual characteristics may be determined or set using different mechanisms.
222 To determine the format of an input file, SoX will use, in order of
223 precedence and as given or available:
224 .IP 1. 4
225 Command-line format options.
226 .IP 2. 4
227 The contents of the file header.
228 .IP 3. 4
229 The filename extension.
231 To set the output file format, SoX will use, in order of
232 precedence and as given or available:
233 .IP 1. 4
234 Command-line format options.
235 .IP 2. 4
236 The filename extension.
237 .IP 3. 4
238 The input file format characteristics, or the closest
239 that is supported by the output file type.
241 For all files, SoX will exit with an error
242 if the file type cannot be determined. Command-line format options may
243 need to be added or changed to resolve the problem.
244 .SS Playing & Recording Audio
246 .B play
248 .B rec
249 commands are provided so that basic playing and
250 recording is as simple as
252    play existing-file.wav
256    rec new-file.wav
258 These two commands are functionally equivalent to
260    sox existing-file.wav \-d
264    sox \-d new-file.wav
266 Of course, further options and effects (as described below) can be
267 added to the commands in either form.
269 center;
270 c8 c8 c.
271 *       *       *
275 Some systems provide more than one type of (SoX-compatible) audio
276 driver, e.g. ALSA & OSS, or SUNAU & AO.
277 Systems can also have more than one audio device (a.k.a. `sound card').
278 If more than one audio driver has been
279 built-in to SoX, and the default selected by SoX when recording or playing
280 is not the one that is wanted, then the
281 .B AUDIODRIVER
282 environment variable can be used to override the default.  For example
283 (on many systems):
285    set AUDIODRIVER=oss
286    play ...
289 .B AUDIODEV
290 environment variable can be used to override the default audio device,
291 e.g.
293    set AUDIODEV=/dev/dsp2
294    play ...
295    sox ... \-t oss
299    set AUDIODEV=hw:soundwave,1,2
300    play ...
301    sox ... \-t alsa
303 Note that the way of setting environment variables varies from system
304 to system\*mfor some specific examples, see `SOX_OPTS' below.
306 When playing a file with a sample rate that is not supported by the
307 audio output device, SoX will automatically invoke the \fBrate\fR effect
308 to perform the necessary sample rate conversion.  For
309 compatibility with old hardware, the
310 default \fBrate\fR quality level is set to `low'. This
311 can be changed by explicitly specifying the \fBrate\fR
312 effect with a different quality level, e.g.
314    play ... rate \-m
316 or by using the
317 .B \-\-play\-rate\-arg
318 option (see below).
320 center;
321 c8 c8 c.
322 *       *       *
326 On some systems, SoX allows audio playback volume to be adjusted whilst
327 using
328 .BR play .
329 Where supported, this is achieved by tapping the `v' & `V' keys during
330 playback.
332 To help with setting a suitable recording level, SoX includes a peak-level
333 meter which can be invoked (before making the actual recording) as follows:
335    rec \-n
337 The recording level should be adjusted (using the system-provided mixer
338 program, not SoX) so that the meter is \fIat most occasionally\fR full
339 scale, and never `in the red' (an exclamation mark is shown).
340 See also \fB\-S\fR below.
341 .SS Accuracy
342 Many file formats that compress audio discard some of the audio signal
343 information whilst doing so. Converting to such a format and then converting
344 back again will not produce an exact copy of the original audio.  This
345 is the case for many formats used in telephony (e.g.  A-law, GSM) where
346 low signal bandwidth is more important than high audio fidelity, and for
347 many formats used in portable music players (e.g. MP3, Vorbis) where
348 adequate fidelity can be retained even with the large compression ratios
349 that are needed to make portable players practical.
351 Formats that discard audio signal information are called `lossy'.
352 Formats that do not are called `lossless'.  The term `quality' is used as a
353 measure of how closely the original audio signal can be reproduced when
354 using a lossy format.
356 Audio file conversion with SoX is lossless when it can be, i.e. when not
357 using lossy compression, when not reducing the sampling rate or number
358 of channels, and when the number of bits used in the destination format
359 is not less than in the source format.  E.g.  converting from an 8-bit
360 PCM format to a 16-bit PCM format is lossless but converting from an
361 8-bit PCM format to (8-bit) A-law isn't.
363 .B N.B.
364 SoX converts all audio files to an internal uncompressed
365 format before performing any audio processing. This means that
366 manipulating a file that is stored in a lossy format can cause further
367 losses in audio fidelity.  E.g. with
369    sox long.mp3 short.mp3 trim 10
371 SoX first decompresses the input MP3 file, then applies the
372 .B trim
373 effect, and finally creates the output MP3 file by re-compressing the
374 audio\*mwith a possible reduction in fidelity above that which
375 occurred when the input file was created.
376 Hence, if what is ultimately desired is lossily compressed audio, it is
377 highly recommended to perform all audio processing using lossless file
378 formats and then convert to the lossy format only at the final stage.
380 .B N.B.
381 Applying multiple effects with a single SoX invocation will,
382 in general, produce more accurate results than those produced using
383 multiple SoX invocations.
384 .SS Dithering
385 Dithering is a technique used to maximise the dynamic range of audio
386 stored at a particular bit-depth. Any distortion introduced by
387 quantisation is decorrelated by adding a small amount of white noise
388 to the signal.  In most cases, SoX can determine whether the selected
389 processing requires dither and will add it during output formatting if
390 appropriate.
392 Specifically, by default, SoX automatically adds TPDF dither
393 when the output bit-depth is less than 24 and any
394 of the following are true:
395 .IP \(bu 4
396 bit-depth reduction has been specified explicitly using a command-line
397 option
398 .IP \(bu 4
399 the output file format supports only bit-depths lower than that of the
400 input file format
401 .IP \(bu 4
402 an effect has increased effective bit-depth within the internal
403 processing chain
405 For example, adjusting volume with
406 .B vol 0.25
407 requires two additional bits in which to losslessly store its results
408 (since 0\*d25 decimal equals 0\*d01 binary).  So if the input file
409 bit-depth is 16, then SoX's internal representation will utilise 18
410 bits after processing this volume change.  In order to store the
411 output at the same depth as the input, dithering is used to remove the
412 additional bits.
414 Use the
415 .B \-V
416 option to see what processing SoX has automatically added. The
417 .B \-D
418 option may be given to override automatic dithering.  To invoke
419 dithering manually (e.g. to select a noise-shaping curve), see the
420 .B dither
421 effect.
422 .SS Clipping
423 Clipping is distortion that occurs when an audio signal level (or
424 `volume') exceeds the range of the chosen representation.  In most
425 cases, clipping is undesirable and so should be corrected by adjusting
426 the level prior to the point (in the processing chain) at which it
427 occurs.
429 In SoX, clipping could occur, as you might expect, when using the
430 .B vol
432 .B gain
433 effects to increase the audio volume. Clipping could also occur with many
434 other effects, when converting one format to another, and even when
435 simply playing the audio.
437 Playing an audio file often involves resampling, and processing by
438 analogue components can introduce a small DC offset and/or
439 amplification, all of which can produce distortion if the audio signal
440 level was initially too close to the clipping point.
442 For these reasons, it is usual to make sure that an audio
443 file's signal level has some `headroom', i.e. it does not exceed a particular
444 level below the maximum possible level for the given representation.
445 Some standards bodies recommend as much as 9dB headroom, but in most cases,
446 3dB (\(~~ 70% linear) is enough.  Note that this wisdom
447 seems to have been lost in modern music production; in fact, many CDs,
448 MP3s, etc.  are now mastered at levels \fIabove\fR 0dBFS i.e. the
449 audio is clipped as delivered.
451 SoX's
452 .B stat
454 .B stats
455 effects can assist in determining the signal level in an audio file. The
456 .B gain
458 .B vol
459 effect can be used to prevent clipping, e.g.
461    sox dull.wav bright.wav gain \-6 treble +6
463 guarantees that the treble boost will not clip.
465 If clipping occurs at any point during processing,
466 SoX will display a warning message to that effect.
468 See also
469 .B \-G
470 and the
471 .B gain
473 .B norm
474 effects.
475 .SS Input File Combining
476 SoX's input combiner can be configured (see OPTIONS below) to
477 combine multiple files using any of the
478 following methods: `concatenate', `sequence', `mix', `mix-power',
479 `merge', or `multiply'.
480 The default method is `sequence' for
481 .BR play ,
482 and `concatenate' for
483 .B rec
485 .BR sox .
487 For all methods other than `sequence', multiple input files must have
488 the same sampling rate. If necessary, separate SoX invocations can be
489 used to make sampling rate adjustments prior to combining.
491 If the `concatenate' combining method is selected (usually, this will be
492 by default) then the input files must also have the same number of
493 channels.  The audio from each input will be concatenated in the order
494 given to form the output file.
496 The `sequence' combining method is selected automatically for
497 .BR play .
498 It is similar to `concatenate' in that the audio from each input file is
499 sent serially to the output file. However, here the output file may be
500 closed and reopened at the corresponding transition between input
501 files. This may be just what is needed when sending different types of
502 audio to an output device, but is not generally useful when the output is a
503 normal file.
505 If either the `mix' or `mix-power' combining method is selected then two or
506 more input files must be given and will be mixed together to form the
507 output file.  The number of channels in each input file need not be the
508 same, but SoX will issue a warning if they are not and some
509 channels in the output file will not contain audio from every input
510 file.  A mixed audio file cannot be un-mixed without reference to the
511 original input files.
513 If the `merge' combining method is selected then two or
514 more input files must be given and will be merged together to form the
515 output file.  The number of channels in each input file need not be the
516 same.  A merged audio file comprises all of the channels from all of the
517 input files. Un-merging is possible using multiple
518 invocations of SoX with the
519 .B remix
520 effect.
521 For example, two mono files could be merged to form one stereo file. The
522 first and second mono files would become the left and right channels of
523 the stereo file.
525 The `multiply' combining method multiplies the sample values of
526 corresponding channels (treated as numbers in the interval \-1 to +1).
527 If the number of channels in the input files is not the same, the
528 missing channels are considered to contain all zero.
530 When combining input files, SoX applies any specified effects
531 (including, for example, the
532 .B vol
533 volume adjustment effect) after the audio has been combined. However, it
534 is often useful to be able to set the volume of (i.e. `balance') the
535 inputs individually, before combining takes place.
537 For all combining methods, input
538 file volume adjustments can be made manually using the
539 .B \-v
540 option (below) which can be given for one or more input files. If it is
541 given for only some of the input files then the others receive no volume
542 adjustment.  In some circumstances, automatic volume
543 adjustments may be applied (see below).
545 The \fB\-V\fR option (below) can be used to show the input file volume
546 adjustments that have been selected (either manually or automatically).
548 There are some special considerations that need to made when mixing
549 input files:
551 Unlike the other methods, `mix' combining has the
552 potential to cause clipping in the combiner if no balancing is
553 performed.  In this case, if manual volume adjustments are not given,
554 SoX will try to ensure that clipping does not occur by automatically
555 adjusting the
556 volume (amplitude) of each input signal by a factor of \(S1/\s-2n\s+2,
557 where n is the number of input files.  If this results in audio that is
558 too quiet or otherwise unbalanced then the input file volumes can be
559 set manually as described above. Using the
560 .B norm
561 effect on the mix is another alternative.
563 If mixed audio seems loud enough at some points but
564 too quiet in others then dynamic range compression should be applied to
565 correct this\*msee the
566 .B compand
567 effect.
569 With the `mix-power' combine method, the
570 mixed volume is approximately equal to that of one of the input signals.
571 This is achieved by balancing using a factor of
572 \(S1/\s-2\(srn\s+2 instead of \(S1/\s-2n\s+2.
573 Note that this balancing factor does not guarantee that clipping will not occur,
574 but the number of clips will usually be low and the resultant
575 distortion is generally imperceptible.
576 .SS Output Files
577 SoX's default behaviour is to take one or more input files and
578 write them to a single output file.
580 This behaviour can be changed by specifying the pseudo-effect `newfile'
581 within the effects list.  SoX will then enter multiple output mode.
583 In multiple output mode, a new file is created when the effects
584 prior to the `newfile' indicate they are done.
585 The effects chain listed after `newfile'
586 is then started up and its output is saved to the new file.
588 In multiple output mode, a unique number will automatically be appended
589 to the end of all filenames.  If the filename has an extension
590 then the number is inserted before the extension.  This behaviour can
591 be customized by placing a %n anywhere in the filename where the
592 number should be substituted.  An optional number can be placed after
593 the % to indicate a minimum fixed width for the number.
595 Multiple output mode is not very useful unless an effect that will
596 stop the effects chain early is
597 specified before the `newfile'. If end of file is
598 reached before the effects chain stops itself then no new file
599 will be created as it would be empty.
601 The following is an example of splitting the first 60 seconds of an input
602 file into two 30 second files and ignoring the rest.
604    sox song.wav ringtone%1n.wav trim 0 30 : newfile : trim 0 30
605 .SS Stopping SoX
606 Usually SoX will complete its processing and exit automatically once
607 it has read all available audio data from the input files.
609 If desired, it can be terminated earlier by sending an
610 interrupt signal to the process (usually by pressing the
611 keyboard interrupt key which is normally Ctrl-C).  This is a natural requirement
612 in some circumstances, e.g. when using SoX to make a recording.  Note
613 that when using SoX to play multiple files, Ctrl-C behaves slightly
614 differently: pressing it once causes SoX to skip to the next file;
615 pressing it twice in quick succession causes SoX to exit.
617 Another option to stop processing early is to use an effect that
618 has a time period or sample count to determine the stopping
619 point. The trim effect is an example of this.  Once all
620 effects chains have stopped then SoX will also stop.
621 .SH FILENAMES
622 Filenames can be simple file names, absolute or relative path names,
623 or URLs (input files only).  Note that URL support requires that
624 .BR wget (1)
625 is available.
627 Note:
628 Giving SoX an input or output filename that is the same as a SoX
629 effect-name will not work since SoX will treat it as an effect
630 specification.  The only work-around to this is to avoid such
631 filenames. This is generally not difficult since most audio
632 filenames have a filename `extension', whilst effect-names do not.
633 .SS Special Filenames
634 The following special filenames may be used in certain circumstances
635 in place of a normal filename on the command line:
637 \fB\-\fR
638 SoX can be used in simple pipeline operations by using the special
639 filename `\-' which,
640 if used as an input filename, will cause
641 SoX will read audio data from `standard input' (stdin),
642 and which,
643 if used as the output filename, will cause
644 SoX will send audio data to `standard output' (stdout).
645 Note that when using this option for the output file, and sometimes
646 when using it for an input file, the file-type (see
647 .B \-t
648 below) must also be given.
650 \fB\(dq\^|\^\fIprogram \fR[\fIoptions\fR] ...\fB\(dq\fR
651 This can be used in place of an input filename to specify the
652 the given program's standard output (stdout) be used as an input file.
653 Unlike
654 .B \-
655 (above), this can be used for several inputs to one SoX command.  For
656 example, if `genw' generates mono WAV formatted signals to its
657 standard output, then the following command makes a stereo file
658 from two generated signals:
660    sox \-M "|genw \-\-imd \-" "|genw \-\-thd \-" out.wav
662 For headerless (raw) audio,
663 .B \-t
664 (and perhaps other format options) will need to be given, preceding the input
665 command.
667 \fB\(dq\fIwildcard-filename\fB\(dq\fR
668 Specifies that filename `globbing' (wild-card matching) should be performed
669 by SoX instead of by the shell.  This allows a single set of file options to be
670 applied to a group of files.  For example, if the current directory contains
671 three `vox' files, file1.vox, file2.vox, and file3.vox, then
673    play \-\-rate 6k *.vox
675 will be expanded by the `shell' (in most environments) to
677    play \-\-rate 6k file1.vox file2.vox file3.vox
679 which will treat only the first vox file as having a sample rate of 6k.
680 With
682    play \-\-rate 6k "*.vox"
684 the given sample rate option will be applied to all three vox files.
686 \fB\-p\fR, \fB\-\-sox\-pipe\fR
687 This can be used in place of an output filename to specify that
688 the SoX command should be used as in input pipe to another SoX command.
689 For example, the command:
691    play "|sox \-n \-p synth 2" "|sox \-n \-p synth 2 tremolo 10" stat
693 plays two `files' in succession, each with different effects.
695 .B \-p
696 is in fact an alias for `\fB\-t sox \-\fR'.
698 \fB\-d\fR, \fB\-\-default\-device\fR
699 This can be used in place of an input or output filename to specify that
700 the default audio device (if one has been built into SoX) is to be used.
701 This is akin to invoking
702 .B rec
704 .B play
705 (as described above).
707 \fB\-n\fR, \fB\-\-null\fR
708 This can be used in place of an input or output filename to specify that
709 a `null file' is to be used.  Note that here, `null file' refers to a
710 SoX-specific mechanism and is not related to any operating-system
711 mechanism with a similar name.
713 Using a null file to input audio is equivalent to
714 using a normal audio file that contains an infinite amount
715 of silence, and as such is not generally useful unless used
716 with an effect that specifies a finite time length
717 (such as \fBtrim\fR or \fBsynth\fR).
719 Using a null file to output audio amounts to discarding the audio
720 and is useful mainly with effects that produce information about the
721 audio instead of affecting it (such as \fBnoiseprof\fR or \fBstat\fR).
723 The sampling rate associated with a null file
724 is by default 48\ kHz, but, as with a normal
725 file, this can be overridden if desired using command-line format
726 options (see below).
727 .SS Supported File & Audio Device Types
729 .BR soxformat (7)
730 for a list and description of the supported file formats and audio device
731 drivers.
732 .SH OPTIONS
733 .SS Global Options
734 These options can be specified on the command line at any point
735 before the first effect name.
738 .B SOX_OPTS
739 environment variable can be used to provide alternative default values for
740 SoX's global options.
741 For example:
743    SOX_OPTS="\-\-buffer 20000 \-\-play-rate-arg \-hs \-\-temp /mnt/temp"
745 Note that setting SOX_OPTS can potentially create unwanted changes in
746 the behaviour of scripts or other programs that invoke SoX.  SOX_OPTS
747 might best be used for things (such as in the given example) that reflect the
748 environment in which SoX is being run.  Enabling options such as
749 .B \-\-no\-clobber
750 as default might be handled better using a shell alias
751 since a shell alias will not affect operation in scripts etc.
753 One way to ensure that a script cannot be affected by SOX_OPTS is to
754 clear SOX_OPTS at the start of the script, but this of course loses
755 the benefit of SOX_OPTS carrying some system-wide default options.  An
756 alternative approach is to explicitly invoke SoX with default
757 option values, e.g.
759    SOX_OPTS="\-V \-\-no-clobber"
760    ...
761    sox \-V2 \-\-clobber $input $output ...
763 Note that the way to set environment variables varies from system
764 to system. Here are some examples:
766 Unix bash:
768    export SOX_OPTS="\-V \-\-no-clobber"
770 Unix csh:
772    setenv SOX_OPTS "\-V \-\-no-clobber"
774 MS-DOS/MS-Windows:
776    set SOX_OPTS=\-V \-\-no-clobber
778 MS-Windows GUI: via Control Panel : System : Advanced : Environment
779 Variables
781 Mac OS X GUI: Refer to Apple's Technical Q&A QA1067 document.
783 \fB\-\-buffer\fR \fBBYTES\fR, \fB\-\-input\-buffer\fR \fBBYTES\fR
784 Set the size in bytes of the buffers used for processing audio (default 8192).
785 .B \-\-buffer
786 applies to input, effects, and output processing;
787 .B \-\-input\-buffer
788 applies only to input processing (for which it overrides
789 .B \-\-buffer
790 if both are given).
792 Be aware that large values for
793 .B \-\-buffer
794 will cause SoX to be become slow to respond to requests to terminate or to skip
795 the current input file.
797 \fB\-\-clobber\fR
798 Don't prompt before overwriting an existing file with the same name as that
799 given for the output file.  This is the default behaviour.
801 \fB\-\-combine concatenate\fR\^|\^\fBmerge\fR\^|\^\fBmix\fR\^|\^\fBmix\-power\fR\^|\^\fBmultiply\fR\^|\^\fBsequence\fR
802 Select the input file combining method;
803 for some of these, short options are available:
804 .B \-m
805 selects `mix',
806 .B \-M
807 selects `merge', and
808 .B \-T
809 selects `multiply'.
811 See \fBInput File Combining\fR above for a description of the different
812 combining methods.
814 \fB\-D\fR, \fB\-\-no\-dither\fR
815 Disable automatic dither\*msee `Dither' above.  An example of why this
816 might occasionally be useful is if a file has been converted from 16 to
817 24 bit with the intention of doing some processing on it, but in fact
818 no processing is needed after all and the original 16 bit file has
819 been lost, then, strictly speaking, no dither is needed if converting the
820 file back to 16 bit.  See also the
821 .B stats
822 effect for how to determine the actual bit depth of the audio within a
823 file.
825 \fB\-\-effects\-file \fIFILENAME\fR
826 Use FILENAME to obtain all effects and their arguments.
827 The file is parsed as if the values were specified on the
828 command line.  A new line can be used in place of the special ":" marker
829 to separate effect chains.  This option causes any effects specified on
830 the command line to be discarded.
832 \fB\-G\fR, \fB\-\-guard\fR
833 Automatically invoke the
834 .B gain
835 effect to guard against clipping. E.g.
837    sox \-G infile \-b 16 outfile rate 44100 dither \-s
839 is shorthand for
841    sox infile \-b 16 outfile gain \-h rate 44100 gain \-rh dither \-s
843 See also
844 .BR \-V,
845 .BR \-\-norm,
846 and the
847 .B gain
848 effect.
850 \fB\-h\fR, \fB\-\-help\fR
851 Show version number and usage information.
853 \fB\-\-help\-effect \fINAME\fR
854 Show usage information on the specified effect.  The name
855 \fBall\fR can be used to show usage on all effects.
857 \fB\-\-help\-format \fINAME\fR
858 Show information about the specified file format.  The name
859 \fBall\fR can be used to show information on all formats.
861 \fB\-\-i\fR, \fB\-\-info\fR
862 Only if given as the first parameter to
863 .BR sox ,
864 behave as
865 .BR soxi (1).
867 \fB\-\-interactive\fR
868 Deprecated alias for \fB\-\-no\-clobber\fR.
870 \fB\-m\fR\^|\^\fB\-M\fR
871 Equivalent to \fB\-\-combine mix\fR and \fB\-\-combine merge\fR, respectively.
873 .B \-\-magic
874 If SoX has been built with the optional `libmagic' library then this
875 option can be given to enable its use in helping to detect audio file types.
877 \fB\-\-multi-threaded\fR | \fB\-\-single-threaded\fR
878 By default, SoX is `single threaded'.
879 If the \fB\-\-multi-threaded\fR option is given however then SoX
880 will process audio channels for most multi-channel
881 effects in parallel on hyper-threading/multi-core architectures. This
882 may reduce processing time, though sometimes it may be necessary to use
883 this option in conjuction with a larger buffer size than is the default
884 to gain any benefit from multi-threaded processing
885 (e.g. 131072; see \fB\-\-buffer\fR above).
887 \fB\-\-no\-clobber\fR
888 Prompt before overwriting an existing file with the same name as that
889 given for the output file.
891 .B N.B.
892 Unintentionally overwriting a file is easier than you might think, for
893 example, if you accidentally enter
895    sox file1 file2 effect1 effect2 ...
897 when what you really meant was
899    play file1 file2 effect1 effect2 ...
901 then, without this option, file2 will be overwritten.  Hence, using
902 this option is recommended. SOX_OPTS (above), a `shell'
903 alias, script, or batch file may be an appropriate way of permanently
904 enabling it.
906 \fB\-\-norm\fR
907 Automatically invoke the
908 .B gain
909 effect to guard against clipping and to normalise the audio. E.g.
911    sox \-\-norm infile \-b 16 outfile rate 44100 dither \-s
913 is shorthand for
915    sox infile \-b 16 outfile gain \-h rate 44100 gain \-nh dither \-s
917 See also
918 .BR \-V,
919 .BR \-G,
920 and the
921 .B gain
922 effect.
924 \fB\-\-play\-rate\-arg ARG\fR
925 Selects a quality option to be used when the `rate' effect is automatically
926 invoked whilst playing audio.  This option is typically set via the
927 .B SOX_OPTS
928 environment variable (see above).
930 \fB\-\-plot gnuplot\fR\^|\^\fBoctave\fR\^|\^\fBoff\fR
931 If not set to
932 .B off
933 (the default if
934 .B \-\-plot
935 is not given), run in a mode that can be used, in conjunction with the
936 gnuplot program or the GNU Octave program, to assist with the selection
937 and configuration of many of the transfer-function based effects.
938 For the first given effect that supports the selected plotting program,
939 SoX will output commands to plot the effect's transfer function, and
940 then exit without actually processing any audio.  E.g.
942    sox \-\-plot octave input-file \-n highpass 1320 > highpass.plt
943    octave highpass.plt
946 \fB\-q\fR, \fB\-\-no\-show\-progress\fR
947 Run in quiet mode when SoX wouldn't otherwise do so.
948 This is the opposite of the \fB\-S\fR option.
950 \fB\-R\fR
951 Run in `repeatable' mode.  When this option is given, where
952 applicable, SoX will embed a fixed time-stamp in the output file (e.g.
953 \fBAIFF\fR) and will `seed' pseudo random number generators (e.g.
954 \fBdither\fR) with a fixed number, thus ensuring that successive SoX
955 invocations with the same inputs and the same parameters yield the
956 same output.
958 \fB\-\-replay\-gain track\fR\^|\^\fBalbum\fR\^|\^\fBoff\fR
959 Select whether or not to apply replay-gain adjustment to input files.
960 The default is
961 .B off
963 .B sox
965 .BR rec ,
966 .B album
968 .B play
969 where (at least) the first two input files are tagged with the same Artist and
970 Album names, and
971 .B track
973 .B play
974 otherwise.
976 \fB\-S\fR, \fB\-\-show\-progress\fR
977 Display input file format/header information, and processing progress as
978 input file(s) percentage complete, elapsed time, and remaining time (if
979 known; shown in brackets), and the number of samples written to the
980 output file.  Also shown is a peak-level meter, and an indication if
981 clipping has occurred.  The peak-level meter shows up to two channels
982 and is calibrated for digital audio as follows (right channel shown):
983 .ne 8
985 center;
986 cI lI cI lI
987 c l c l.
988 dB FSD  Display dB FSD  Display
989 \-25    \-      \-11    ====
990 \-23    T{
992 T}      \-9     ====\-
993 \-21    =\-     \-7     =====
994 \-19    ==      \-5     =====\-
995 \-17    ==\-    \-3     ======
996 \-15    ===     \-1     =====!
997 \-13    ===\-
1001 A three-second peak-held value of headroom in dBs will be shown to the right
1002 of the meter if this is below 6dB.
1004 This option is enabled by default when using
1005 SoX to play or record audio.
1007 \fB\-T\fR\fR
1008 Equivalent to \fB\-\-combine multiply\fR.
1010 \fB\-\-temp\fI DIRECTORY\fR
1011 Specify that any temporary files should be created in the given
1012 .IR DIRECTORY .
1013 This can be useful if there are permission or free-space problems with the
1014 default location. In this case, using `\fB\-\-temp .\fR' (to use the
1015 current directory) is often a good solution.
1017 \fB\-\-version\fR
1018 Show SoX's version number and exit.
1019 .IP \fB\-V\fB[\fIlevel\fB]\fP
1020 Set verbosity. This is particularly useful for seeing how any automatic
1021 effects have been invoked by SoX.
1023 SoX displays messages on the console (stderr) according to the following
1024 verbosity levels:
1027 .IP 0
1028 No messages are shown at all; use the exit status to determine
1029 if an error has occurred.
1030 .IP 1
1031 Only error messages are shown.  These are generated if
1032 SoX cannot complete the requested commands.
1033 .IP 2
1034 Warning messages are also shown.  These are generated if
1035 SoX can complete the requested commands,
1036 but not exactly according to the requested command parameters,
1037 or if clipping occurs.
1038 .IP 3
1039 Descriptions of
1040 SoX's processing phases are also shown.
1041 Useful for seeing exactly how
1042 SoX is processing your audio.
1043 .IP "4 and above"
1044 Messages to help with debugging
1045 SoX are also shown.
1048 By default, the verbosity level is set to 2 (shows errors and
1049 warnings). Each occurrence of the \fB\-V\fR option increases the
1050 verbosity level by 1.  Alternatively, the verbosity level can be set
1051 to an absolute number by specifying it immediately after the
1052 .BR \-V ,
1053 e.g.
1054 .B \-V0
1055 sets it to 0.
1057 .SS Input File Options
1058 These options apply only to input files and may precede only input
1059 filenames on the command line.
1061 \fB\-\-ignore-length\fR
1062 Override an (incorrect) audio length given in an audio file's header. If
1063 this option is given then SoX will keep reading audio until it reaches
1064 the end of the input file.
1066 \fB\-v\fR, \fB\-\-volume\fR \fIFACTOR\fR
1067 Intended for use when combining multiple input files, this option
1068 adjusts the volume of the file that follows it on the command line by a
1069 factor of \fIFACTOR\fR. This allows it to be `balanced' w.r.t. the other
1070 input files.  This is a linear (amplitude) adjustment, so a number less
1071 than 1 decreases the volume and a number greater than 1 increases it.  If a
1072 negative number is given then in addition to the volume adjustment,
1073 the audio signal will be inverted.
1075 See also the
1076 .BR norm ,
1077 .BR vol ,
1079 .B gain
1080 effects, and see \fBInput File Balancing\fR above.
1081 .SS Input & Output File Format Options
1082 These options apply to the input or output file whose name they
1083 immediately precede on the command line and are used mainly when
1084 working with headerless file formats or when specifying a format
1085 for the output file that is different to that of the input file.
1087 \fB\-b\fR \fIBITS\fR, \fB\-\-bits\fR \fIBITS\fR
1088 The number of bits (a.k.a. bit-depth or sometimes word-length) in each
1089 encoded sample.  Not applicable to complex encodings such as MP3 or GSM.
1090 Not necessary with encodings that have a fixed number of bits, e.g.
1091 A/\(*m-law, ADPCM.
1093 For an input file, the most common use for this option is to inform
1094 SoX of the number of bits per sample in a `raw' (`headerless') audio
1095 file.  For example
1097    sox \-r 16k \-e signed \-b 8 input.raw output.wav
1099 converts a particular `raw' file to a self-describing `WAV' file.
1101 For an output file, this option can be used (perhaps along with
1102 .BR \-e )
1103 to set the output encoding size.  By default (i.e. if this option is
1104 not given), the output encoding size will (providing it is supported
1105 by the output file type) be set to the input encoding size.  For
1106 example
1108    sox input.cdda \-b 24 output.wav
1110 converts raw CD digital audio (16-bit, signed-integer) to a
1111 24-bit (signed-integer) `WAV' file.
1113 \fB\-1\fR\^/\fB\-2\fR\^/\fB\-3\fR\^/\fB\-4\fR\^/\fB\-8\fR
1114 The number of bytes in each encoded sample.  Deprecated aliases for
1115 \fB\-b 8\fR, \fB\-b 16\fR, \fB\-b 24\fR, \fB\-b 32\fR, \fB\-b 64\fR
1116 respectively.
1118 \fB\-c\fR \fICHANNELS\fR, \fB\-\-channels\fR \fICHANNELS\fR
1119 The number of audio channels in the audio file. This can be any number
1120 greater than zero.
1122 For an input file, the most common use for this option is to inform
1123 SoX of the number of channels in a `raw' (`headerless') audio file.
1124 Occasionally, it may be useful to use this option with a `headered'
1125 file, in order to override the (presumably incorrect) value in the
1126 header\*mnote that this is only supported with certain file types.
1127 Examples:
1129    sox \-r 48k \-e float \-b 32 \-c 2 input.raw output.wav
1131 converts a particular `raw' file to a self-describing `WAV' file.
1133    play \-c 1 music.wav
1135 interprets the file data as belonging to a single channel regardless
1136 of what is indicated in the file header.  Note that if the file does
1137 in fact have two channels, this will result in the file playing at
1138 half speed.
1140 For an output file, this option provides a shorthand for specifying
1141 that the
1142 .B channels
1143 effect should be invoked in order to change (if necessary) the number
1144 of channels in the audio signal to the number given.  For
1145 example, the following two commands are equivalent:
1147 .ne 2
1148    sox input.wav \-c 1 output.wav bass \-3
1149    sox input.wav      output.wav bass \-3 channels 1
1151 though the second form is more flexible as it allows the effects to
1152 be ordered arbitrarily.
1154 \fB\-e \fIENCODING\fR, \fB\-\-encoding\fR \fIENCODING\fR
1155 The audio encoding type.  Sometimes needed with file-types that
1156 support more than one encoding type. For example, with raw, WAV, or
1157 AU (but not, for example, with MP3 or FLAC).
1158 The available encoding types are as follows:
1160 .IP \fBsigned-integer\fR
1161 PCM data stored as signed (`two's complement') integers.  Commonly used
1162 with a 16 or 24 \-bit encoding size.
1163 A value of 0 represents minimum signal power.
1164 .IP \fBunsigned-integer\fR
1165 PCM data stored as signed (`two's complement') integers.  Commonly used
1166 with an 8-bit encoding size.  A value of 0 represents maximum signal
1167 power.
1168 .IP \fBfloating-point\fR
1169 PCM data stored as IEEE 753 single precision (32-bit) or double
1170 precision (64-bit) floating-point (`real') numbers.
1171 A value of 0 represents minimum signal power.
1172 .IP \fBa-law\fR
1173 International telephony standard for logarithmic encoding to 8 bits per
1174 sample.  It has a precision equivalent to roughly 13-bit PCM and is
1175 sometimes encoded with reversed bit-ordering (see the
1176 .B \-X
1177 option).
1178 .IP \fBu-law,\ mu-law\fR
1179 North American telephony standard for logarithmic encoding to 8 bits per
1180 sample.  A.k.a. \(*m-law.  It has a precision equivalent to roughly
1181 14-bit PCM and is
1182 sometimes encoded with reversed bit-ordering (see the
1183 .B \-X
1184 option).
1185 .IP \fBoki-adpcm\fR
1186 OKI (a.k.a. VOX, Dialogic, or Intel) 4-bit ADPCM;
1187 it has a precision equivalent to roughly 12-bit PCM.
1188 ADPCM is a form of audio compression that has a good
1189 compromise between audio quality and encoding/decoding speed.
1190 .IP \fBima-adpcm\fR
1191 IMA (a.k.a. DVI) 4-bit ADPCM;
1192 it has a precision equivalent to roughly 13-bit PCM.
1193 .IP \fBms-adpcm\fR
1194 Microsoft 4-bit ADPCM; it has a precision equivalent to roughly 14-bit
1195 PCM.
1196 .IP \fBgsm-full-rate\fR
1197 GSM is currently used for the vast majority of the world's digital
1198 wireless telephone calls.  It utilises several audio
1199 formats with different bit-rates and associated speech quality.
1200 SoX has support for GSM's original 13kbps `Full Rate' audio format.
1201 It is usually CPU-intensive to work with GSM audio.
1205 Encoding names can be abbreviated where this would not be ambiguous;
1206 e.g. `unsigned-integer' can be given as `un', but not `u' (ambiguous
1207 with `u-law').
1209 For an input file, the most common use for this option is to inform
1210 SoX of the encoding of a `raw' (`headerless') audio
1211 file (see the examples in
1212 .B \-b
1214 .B \-c
1215 above).
1217 For an output file, this option can be used (perhaps along with
1218 .BR \-b )
1219 to set the output encoding type  For example
1221    sox input.cdda \-e float output1.wav
1223    sox input.cdda \-b 64 \-e float output2.wav
1225 convert raw CD digital audio (16-bit, signed-integer) to
1226 floating-point `WAV' files (single & double precision respectively).
1228 By default (i.e. if this option is not given), the output encoding
1229 type will (providing it is supported by the output file type) be set
1230 to the input encoding type.
1232 \fB\-s\fR\^/\fB\-u\fR\^/\fB\-f\fR\^/\fB\-A\fR\^/\fB\-U\fR\^/\fB\-o\fR\^/\fB\-i\fR\^/\fB\-a\fR\^/\fB\-g\fR
1233 Deprecated aliases for specifying the encoding types
1234 \fBsigned-integer\fR, \fBunsigned-integer\fR, \fBfloating-point\fR, \fBmu-law\fR, \fBa-law\fR, \fBoki-adpcm\fR, \fBima-adpcm\fR, \fBms-adpcm\fR, \fBgsm-full-rate\fR
1235 respectively (see
1236 .B \-e
1237 above).
1239 \fB\-\-no\-glob\fR
1240 Specifies that filename `globbing' (wild-card matching) should not be
1241 performed by SoX on the following filename.  For example, if the current
1242 directory contains the two files `five-seconds.wav' and `five*.wav', then
1244    play \-\-no-glob "five*.wav"
1246 can be used to play just the single file `five*.wav'.
1248 \fB\-r, \fB\-\-rate\fR \fIRATE\fR[\fBk\fR]
1249 Gives the sample rate in Hz (or kHz if appended with `k') of the file.
1251 For an input file, the most common use for this option is to inform
1252 SoX of the sample rate of a `raw' (`headerless') audio file (see the
1253 examples in
1254 .B \-b
1256 .B \-c
1257 above).
1258 Occasionally it may be useful to use this option with a `headered'
1259 file, in order to override the (presumably incorrect) value in the
1260 header\*mnote that this is only supported with certain file types.
1261 For example, if audio was recorded with a sample-rate of say 48k from
1262 a source that played back a little, say 1\*d5%, too slowly, then
1264    sox \-r 48720 input.wav output.wav
1266 effectively corrects the speed by changing only the file header (but see
1267 also the
1268 .B speed
1269 effect for the more usual solution to this problem).
1271 For an output file, this option provides a shorthand for specifying
1272 that the
1273 .B rate
1274 effect should be invoked in order to change (if necessary) the sample
1275 rate of the audio signal to the given value.  For example, the
1276 following two commands are equivalent:
1278 .ne 2
1279    sox input.wav \-r 48k output.wav bass \-3
1280    sox input.wav        output.wav bass \-3 rate 48k
1282 though the second form is more flexible as it allows
1283 .B rate
1284 options to be given, and allows the effects to be ordered arbitrarily.
1286 \fB\-t\fR, \fB\-\-type\fR \fIFILE-TYPE\fR
1287 Gives the type of the audio file.  For both input and output files,
1288 this option is commonly used to inform SoX of the type a `headerless'
1289 audio file (e.g. raw, mp3) where the actual/desired type cannot be
1290 determined from a given filename extension.  For example:
1292    another-command | sox \-t mp3 \- output.wav
1294    sox input.wav \-t raw output.bin
1296 It can also be used to override the type implied by an input filename
1297 extension, but if overriding with a type that has a header, SoX will
1298 exit with an appropriate error message if such a header is not
1299 actually present.
1302 .BR soxformat (7)
1303 for a list of supported file types.
1305 \fB\-L\fR, \fB\-\-endian little\fR
1307 \fB\-B\fR, \fB\-\-endian big\fR
1309 \fB\-x\fR, \fB\-\-endian swap\fR
1310 .if t .sp -.5
1311 .if n .sp -1
1314 These options specify whether the byte-order of the audio data is,
1315 respectively, `little endian', `big endian', or the opposite to that of
1316 the system on which SoX is being used.  Endianness applies only to data
1317 encoded as floating-pont, or as signed or unsigned integers of 16 or
1318 more bits.  It is often necessary to specify one of these options for
1319 headerless files, and sometimes necessary for (otherwise)
1320 self-describing files.  A given endian-setting option may be ignored
1321 for an input file whose header contains a specific endianness
1322 identifier, or for an output file that is actually an audio device.
1324 .B N.B.
1325 Unlike other format characteristics, the endianness (byte, nibble, &
1326 bit ordering) of the input file is not automatically used for the output
1327 file; so, for example, when the following is run on a little-endian system:
1329    sox \-B audio.s16 trimmed.s16 trim 2
1331 trimmed.s16 will be created as little-endian;
1333    sox \-B audio.s16 \-B trimmed.s16 trim 2
1335 must be used to preserve big-endianness in the output file.
1338 .B \-V
1339 option can be used to check the selected orderings.
1341 \fB\-N\fR, \fB\-\-reverse\-nibbles\fR
1342 Specifies that the nibble ordering (i.e. the 2 halves of a byte) of the samples should be reversed;
1343 sometimes useful with ADPCM-based formats.
1345 .B N.B.
1346 See also N.B. in section on
1347 .B \-x
1348 above.
1350 \fB\-X\fR, \fB\-\-reverse\-bits\fR
1351 Specifies that the bit ordering of the samples should be reversed;
1352 sometimes useful with a few (mostly headerless) formats.
1354 .B N.B.
1355 See also N.B. in section on
1356 .B \-x
1357 above.
1358 .SS Output File Format Options
1359 These options apply only to the output file and may precede only the output
1360 filename on the command line.
1362 \fB\-\-add\-comment \fITEXT\fR
1363 Append a comment in the output file header (where applicable).
1365 \fB\-\-comment \fITEXT\fR
1366 Specify the comment text to store in the output file header (where
1367 applicable).
1369 SoX will provide a default comment if this option (or
1370 .BR \-\-comment\-file )
1371 is not given. To specify that no comment should be stored in the output file,
1373 .B "\-\-comment \(dq\(dq" .
1375 \fB\-\-comment\-file \fIFILENAME\fR
1376 Specify a file containing the comment text to store in the output
1377 file header (where applicable).
1379 \fB\-C\fR, \fB\-\-compression\fR \fIFACTOR\fR
1380 The compression factor for variably compressing output file formats.  If
1381 this option is not given then a default compression factor will apply.
1382 The compression factor is interpreted differently for different
1383 compressing file formats.  See the description of the file formats that
1384 use this option in
1385 .BR soxformat (7)
1386 for more information.
1387 .SH EFFECTS
1388 In addition to converting, playing and recording audio files, SoX can
1389 be used to invoke a number of audio `effects'.  Multiple effects may
1390 be applied by specifying them one after another at the end of the SoX
1391 command line, forming an `effects chain'.
1392 Note that applying multiple effects in real-time (i.e. when playing audio)
1393 is likely to require a high performance computer. Stopping other applications
1394 may alleviate performance issues should they occur.
1396 Some of the SoX effects are primarily intended to be applied to a single
1397 instrument or `voice'.  To facilitate this, the \fBremix\fR effect and
1398 the global SoX option \fB\-M\fR can be used to isolate then recombine
1399 tracks from a multi-track recording.
1400 .SS Multiple Effect Chains
1401 A single effects chain is made up of one or more effects.  Audio from
1402 the input runs through the chain until either the end of the input file
1403 is reached or an effect in the chain requests to terminate the chain.
1405 SoX supports running multiple effects chains over the input audio.
1406 In this case, when one chain indicates it is done processing audio,
1407 the audio data is then sent through the next effects chain.  This
1408 continues until either no more effects chains exist or the input has
1409 reached the end of the file.
1411 An effects chain is terminated by placing a
1412 .B :
1413 (colon) after an effect.  Any following effects are a part of a new effects chain.
1415 It is important to place the effect that will stop the chain
1416 as the first effect in the chain.  This is because any samples
1417 that are buffered by effects to the left of the terminating effect
1418 will be discarded.  The amount of samples discarded is related to the
1419 .B \-\-buffer
1420 option and it should be kept small, relative to the sample rate, if
1421 the terminating effect cannot be first.  Further information on
1422 stopping effects can be found in the
1423 .B Stopping SoX
1424 section.
1426 There are a few pseudo-effects that aid using multiple effects chains.
1427 These include
1428 .B newfile
1429 which will start writing to a new output file before moving to the
1430 next effects chain and
1431 .B restart
1432 which will move back to the first effects chain.  Pseudo-effects
1433 must be specified as the first effect in a chain and as the only
1434 effect in a chain (they must have a
1435 .B :
1436 before and after they are specified).
1438 The following is an example of multiple effects chains.  It will split the
1439 input file into multiple files of 30 seconds in length.  Each output filename
1440 will have unique number in its name as documented in the
1441 .B Output Files
1442 section.
1444    sox infile.wav output.wav trim 0 30 : newfile : restart
1446 .SS Common Notation And Parameters
1447 In the descriptions that follow,
1448 brackets [ ] are used to denote parameters that are optional, braces
1449 { } to denote those that are both optional and repeatable,
1450 and angle brackets < > to denote those that are repeatable but not
1451 optional.
1452 Where applicable, default values for optional parameters are shown in parenthesis ( ).
1454 The following parameters are used with, and have the same meaning for,
1455 several effects:
1457 \fIcentre\fR[\fBk\fR]
1459 .IR frequency .
1461 \fIfrequency\fR[\fBk\fR]
1462 A frequency in Hz, or, if appended with `k', kHz.
1464 \fIgain\fR
1465 A power gain in dB.
1466 Zero gives no gain; less than zero gives an attenuation.
1468 \fIwidth\fR[\fBh\fR\^|\^\fBk\fR\^|\^\fBo\fR\^|\^\fBq\fR]
1469 Used to specify the band-width of a filter.  A number of different
1470 methods to specify the width are available (though not all for every effect).
1471 One of the characters shown may be appended to select the desired method
1472 as follows:
1473 .ne 5
1475 center;
1476 cI cI lI
1477 cB c l.
1478 \       Method  Notes
1479 h       Hz      \ 
1480 k       kHz     \ 
1481 o       Octaves \ 
1482 q       Q-factor        See [2]
1486 For each effect that uses this parameter, the default method (i.e. if no
1487 character is appended) is the one that it listed first in the first line of
1488 the effect's description.
1490 To see if SoX has support for an optional effect, enter
1491 .B sox \-h
1492 and look for its name under the list: `EFFECTS'.
1493 .SS Supported Effects
1494 Note: a categorised list of the effects can be found in the
1495 accompanying `README' file.
1497 \fBallpass\fR \fIfrequency\fR[\fBk\fR]\fI width\fR[\fBh\fR\^|\^\fBk\fR\^|\^\fBo\fR\^|\^\fBq\fR]
1498 Apply a two-pole all-pass filter with central frequency (in Hz)
1499 \fIfrequency\fR, and filter-width \fIwidth\fR.
1500 An all-pass filter changes the
1501 audio's frequency to phase relationship without changing its frequency
1502 to amplitude relationship.  The filter is described in detail in [1].
1504 This effect supports the \fB\-\-plot\fR global option.
1506 \fBband\fR [\fB\-n\fR] \fIcenter\fR[\fBk\fR]\fR [\fIwidth\fR[\fBh\fR\^|\^\fBk\fR\^|\^\fBo\fR\^|\^\fBq\fR]]
1507 Apply a band-pass filter.
1508 The frequency response drops logarithmically
1509 around the
1510 .I center
1511 frequency.
1513 .I width
1514 parameter gives the slope of the drop.
1515 The frequencies at
1516 .I center
1518 .I width
1520 .I center
1522 .I width
1523 will be half of their original amplitudes.
1524 .B band
1525 defaults to a mode oriented to pitched audio,
1526 i.e. voice, singing, or instrumental music.
1527 The \fB\-n\fR (for noise) option uses the alternate mode
1528 for un-pitched audio (e.g. percussion).
1529 .B Warning:
1530 \fB\-n\fR introduces a power-gain of about 11dB in the filter, so beware
1531 of output clipping.
1532 .B band
1533 introduces noise in the shape of the filter,
1534 i.e. peaking at the
1535 .I center
1536 frequency and settling around it.
1538 This effect supports the \fB\-\-plot\fR global option.
1540 See also \fBsinc\fR for a bandpass filter with steeper shoulders.
1542 \fBbandpass\fR\^|\^\fBbandreject\fR [\fB\-c\fR] \fIfrequency\fR[\fBk\fR]\fI width\fR[\fBh\fR\^|\^\fBk\fR\^|\^\fBo\fR\^|\^\fBq\fR]
1543 Apply a two-pole Butterworth band-pass or band-reject filter with
1544 central frequency \fIfrequency\fR, and (3dB-point) band-width
1545 \fIwidth\fR.  The
1546 .B \-c
1547 option applies only to
1548 .B bandpass
1549 and selects a constant skirt gain (peak gain = Q) instead of the
1550 default: constant 0dB peak gain.
1551 The filters roll off at 6dB per octave (20dB per decade)
1552 and are described in detail in [1].
1554 These effects support the \fB\-\-plot\fR global option.
1556 See also \fBsinc\fR for a bandpass filter with steeper shoulders.
1558 \fBbandreject \fIfrequency\fR[\fBk\fR]\fI width\fR[\fBh\fR\^|\^\fBk\fR\^|\^\fBo\fR\^|\^\fBq\fR]
1559 Apply a band-reject filter.
1560 See the description of the \fBbandpass\fR effect for details.
1562 \fBbass\fR\^|\^\fBtreble \fIgain\fR [\fIfrequency\fR[\fBk\fR]\fR [\fIwidth\fR[\fBs\fR\^|\^\fBh\fR\^|\^\fBk\fR\^|\^\fBo\fR\^|\^\fBq\fR]]]
1563 Boost or cut the bass (lower) or treble (upper) frequencies of the audio
1564 using a two-pole shelving filter with a response similar to that
1565 of a standard hi-fi's tone-controls.  This is also
1566 known as shelving equalisation (EQ).
1568 \fIgain\fR gives the gain at 0\ Hz (for \fBbass\fR), or whichever is
1569 the lower of \(ap22\ kHz and the Nyquist frequency (for \fBtreble\fR).  Its
1570 useful range is about \-20 (for a large cut) to +20 (for a large
1571 boost).
1572 Beware of
1573 .B Clipping
1574 when using a positive \fIgain\fR.
1576 If desired, the filter can be fine-tuned using the following
1577 optional parameters:
1579 \fIfrequency\fR sets the filter's central frequency and so can be
1580 used to extend or reduce the frequency range to be boosted or
1581 cut.  The default value is 100\ Hz (for \fBbass\fR) or 3\ kHz (for
1582 \fBtreble\fR).
1584 \fIwidth\fR
1585 determines how
1586 steep is the filter's shelf transition.  In addition to the common
1587 width specification methods described above,
1588 `slope' (the default, or if appended with `\fBs\fR') may be used.
1589 The useful range of `slope' is
1590 about 0\*d3, for a gentle slope, to 1 (the maximum), for a steep slope; the
1591 default value is 0\*d5.
1593 The filters are described in detail in [1].
1595 These effects support the \fB\-\-plot\fR global option.
1597 See also \fBequalizer\fR for a peaking equalisation effect.
1599 \fBbend\fR [\fB\-f \fIframe-rate\fR(25)] [\fB\-o \fIover-sample\fR(16)] { \fIdelay\fB,\fIcents\fB,\fIduration\fR }
1600 Changes pitch by specified amounts at specified times.
1601 Each given triple: \fIdelay\fB,\fIcents\fB,\fIduration\fR specifies one bend.
1602 .I delay
1603 is the amount of time after the start of the audio stream, or the end of the previous bend, at which to start bending the pitch;
1604 .I cents
1605 is the number of cents (100 cents = 1 semitone) by which to bend the pitch, and
1606 .I duration
1607 the length of time over which the pitch will be bent.
1609 The pitch-bending algorithm utilises the Discrete Fourier Transform (DFT)
1610 at a particular frame rate and over-sampling rate.
1612 .B \-f
1614 .B \-o
1615 parameters may be used to adjust these parameters and thus control the
1616 smoothness of the changes in pitch.
1618 For example, an initial tone is generated, then bent three times, yielding
1619 four different notes in total:
1621 .ne 2
1622    play \-n synth 2.5 sin 667 gain 1 \\
1623         bend .35,180,.25  .15,740,.53  0,\-520,.3
1625 Note that the clipping that is produced in this example is deliberate;
1626 to remove it, use
1627 .B gain\ \-5
1628 in place of
1629 .BR gain\ 1 .
1631 \fBbiquad \fIb0 b1 b2 a0 a1 a2\fR
1632 Apply a biquad IIR filter with the given coefficients. Where b* and a* are
1633 the numerator and denominator coefficients respectively.
1635 See http://en.wikipedia.org/wiki/Digital_biquad_filter (where a0 = 1).
1637 \fBchannels \fICHANNELS\fR
1638 Invoke a simple algorithm to change the number of channels in
1639 the audio signal to the given number
1640 .IR CHANNELS :
1641 mixing if decreasing the number of channels or duplicating if
1642 increasing the number of channels.
1645 .B channels
1646 effect is invoked automatically if SoX's \fB\-c\fR option specifies a
1647 number of channels that is different to that of the input file(s).
1648 Alternatively, if this effect is given explicitly, then SoX's
1649 .B \-c
1650 option need not be given.  For example, the following two commands are
1651 equivalent:
1653 .ne 2
1654    sox input.wav \-c 1 output.wav bass \-3
1655    sox input.wav      output.wav bass \-3 channels 1
1657 though the second form is more flexible as it allows the effects to
1658 be ordered arbitrarily.
1660 See also
1661 .B remix
1662 for an effect that allows channels to be mixed/selected arbitrarily.
1664 \fBchorus \fIgain-in gain-out\fR <\fIdelay decay speed depth \fB\-s\fR\^|\^\fB\-t\fR>
1665 Add a chorus effect to the audio.  This can make a single vocal sound
1666 like a chorus, but can also be applied to instrumentation.
1668 Chorus resembles an echo effect with a short delay, but
1669 whereas with echo the delay is constant, with chorus, it
1670 is varied using sinusoidal or triangular modulation.  The modulation
1671 depth defines the range the modulated delay is played before or after the
1672 delay. Hence the delayed sound will sound slower or faster, that is the delayed
1673 sound tuned around the original one, like in a chorus where some vocals are
1674 slightly off key.
1675 See [3] for more discussion of the chorus effect.
1677 Each four-tuple parameter
1678 delay/decay/speed/depth gives the delay in milliseconds
1679 and the decay (relative to gain-in) with a modulation
1680 speed in Hz using depth in milliseconds.
1681 The modulation is either sinusoidal (\fB\-s\fR) or triangular
1682 (\fB\-t\fR).  Gain-out is the volume of the output.
1684 A typical delay is around 40ms to 60ms; the modulation speed is best
1685 near 0\*d25Hz and the modulation depth around 2ms.
1686 For example, a single delay:
1688    play guitar1.wav chorus 0.7 0.9 55 0.4 0.25 2 \-t
1690 Two delays of the original samples:
1692 .ne 2
1693    play guitar1.wav chorus 0.6 0.9 50 0.4 0.25 2 \-t \\
1694          60 0.32 0.4 1.3 \-s
1696 A fuller sounding chorus (with three additional delays):
1698 .ne 2
1699    play guitar1.wav chorus 0.5 0.9 50 0.4 0.25 2 \-t \\
1700          60 0.32 0.4 2.3 \-t 40 0.3 0.3 1.3 \-s
1703 \fBcompand \fIattack1\fB,\fIdecay1\fR{\fB,\fIattack2\fB,\fIdecay2\fR}
1704 [\fIsoft-knee-dB\fB:\fR]\fIin-dB1\fR[\fB,\fIout-dB1\fR]{\fB,\fIin-dB2\fB,\fIout-dB2\fR}
1706 [\fIgain\fR [\fIinitial-volume-dB\fR [\fIdelay\fR]]]
1708 Compand (compress or expand) the dynamic range of the audio.
1711 .I attack
1713 .I decay
1714 parameters (in seconds) determine the time over which the
1715 instantaneous level of the input signal is averaged to determine its
1716 volume; attacks refer to increases in volume and decays refer to
1717 decreases.
1718 For most situations, the attack time (response to the music getting
1719 louder) should be shorter than the decay time because the human ear is more
1720 sensitive to sudden loud music than sudden soft music.
1721 Where more than one pair of attack/decay parameters are
1722 specified, each input channel is companded separately and the number of
1723 pairs must agree with the number of input channels.
1724 Typical values are
1725 .B 0\*d3,0\*d8
1726 seconds.
1728 The second parameter is a list of points on the compander's transfer
1729 function specified in dB relative to the maximum possible signal
1730 amplitude.  The input values must be in a strictly increasing order but
1731 the transfer function does not have to be monotonically rising.  If
1732 omitted, the value of
1733 .I out-dB1
1734 defaults to the same value as
1735 .IR in-dB1 ;
1736 levels below
1737 .I in-dB1
1738 are not companded (but may have gain applied to them).
1739 The point \fB0,0\fR is assumed but may be overridden (by
1740 \fB0,\fIout-dBn\fR).
1741 If the list is preceded by a
1742 .I soft-knee-dB
1743 value, then the points at where adjacent line segments on the
1744 transfer function meet will be rounded by the amount given.
1745 Typical values for the transfer function are
1746 .BR 6:\-70,\-60,\-20 .
1748 The third (optional) parameter is an additional gain in dB to be applied
1749 at all points on the transfer function and allows easy adjustment
1750 of the overall gain.
1752 The fourth (optional) parameter is an initial level to be assumed for
1753 each channel when companding starts.  This permits the user to supply a
1754 nominal level initially, so that, for example, a very large gain is not
1755 applied to initial signal levels before the companding action has begun
1756 to operate: it is quite probable that in such an event, the output would
1757 be severely clipped while the compander gain properly adjusts itself.
1758 A typical value (for audio which is initially quiet) is
1759 .B \-90
1762 The fifth (optional) parameter is a delay in seconds.  The input signal
1763 is analysed immediately to control the compander, but it is delayed
1764 before being fed to the volume adjuster.  Specifying a delay
1765 approximately equal to the attack/decay times allows the compander to
1766 effectively operate in a `predictive' rather than a reactive mode.
1767 A typical value is
1768 .B 0\*d2
1769 seconds.
1771 center;
1772 c8 c8 c.
1773 *       *       *
1777 The following example might be used to make a piece of music with both
1778 quiet and loud passages suitable for listening to in a noisy environment
1779 such as a moving vehicle:
1781    sox asz.wav asz-car.wav compand 0.3,1 6:\-70,\-60,\-20 \-5 \-90 0.2
1783 The transfer function (`6:\-70,...') says that very soft sounds (below
1784 \-70dB) will remain unchanged.  This will stop the compander from
1785 boosting the volume on `silent' passages such as between movements.
1786 However, sounds in the range \-60dB to 0dB (maximum
1787 volume) will be boosted so that the 60dB dynamic range of the
1788 original music will be compressed 3-to-1 into a 20dB range, which is
1789 wide enough to enjoy the music but narrow enough to get around the
1790 road noise.  The `6:' selects 6dB soft-knee companding.
1791 The \-5 (dB) output gain is needed to avoid clipping (the number is
1792 inexact, and was derived by experimentation).
1793 The \-90 (dB) for the initial volume will work fine for a clip that starts
1794 with near silence, and the delay of 0\*d2 (seconds) has the effect of causing
1795 the compander to react a bit more quickly to sudden volume changes.
1797 In the next example, compand is being used as a noise-gate for when the
1798 noise is at a lower level than the signal:
1800    play infile compand .1,.2 \-inf,\-50.1,\-inf,\-50,\-50 0 \-90 .1
1802 Here is another noise-gate, this time for when the
1803 noise is at a higher level than the signal (making it, in some ways,
1804 similar to squelch):
1806    play infile compand .1,.1 \-45.1,\-45,\-inf,0,\-inf 45 \-90 .1
1808 This effect supports the \fB\-\-plot\fR global option (for the transfer function).
1810 See also
1811 .B mcompand
1812 for a multiple-band companding effect.
1814 \fBcontrast \fR[\fIenhancement-amount\fR(75)]
1815 Comparable with compression, this effect modifies an audio signal to
1816 make it sound louder.
1817 .I enhancement-amount
1818 controls the amount of the enhancement and is a number in the range 0\-100.
1819 Note that
1820 .I enhancement-amount
1821 = 0 still gives a significant contrast enhancement.
1823 See also the
1824 .B compand
1826 .B mcompand
1827 effects.
1829 \fBdcshift \fIshift\fR [\fIlimitergain\fR]
1830 Apply a DC shift to the audio.  This can be useful to remove a DC
1831 offset (caused perhaps by a hardware problem in the recording chain)
1832 from the audio.  The effect of a DC offset is reduced headroom and
1833 hence volume.
1835 .B stat
1837 .B stats
1838 effect can be used to determine if a signal has a DC offset.
1840 The given \fIdcshift\fR value is a floating point number in the range
1841 of \(+-2 that indicates the amount to shift the audio (which is in the
1842 range of \(+-1).
1844 An optional
1845 .I limitergain
1846 can be specified as well.  It should have a value much less than 1
1847 (e.g. 0\*d05 or 0\*d02) and is used only on peaks to prevent clipping.
1849 center;
1850 c8 c8 c.
1851 *       *       *
1855 An alternative approach to removing a DC offset (albeit with a short delay)
1856 is to use the
1857 .B highpass
1858 filter effect at a frequency of say 10Hz, as illustrated in the following
1859 example:
1861    sox \-n dc.wav synth 5 sin %0 50
1862    sox dc.wav fixed.wav highpass 10
1865 \fBdeemph\fR
1866 Apply Compact Disc (IEC 60908) de-emphasis (a treble attenuation shelving
1867 filter).
1869 Pre-emphasis was applied in the mastering of some CDs issued in the early
1870 1980s.  These included many classical music albums, as well as now
1871 sought-after issues of albums by The Beatles, Pink Floyd and others.
1872 Pre-emphasis should be removed at playback time by a de-emphasis
1873 filter in the playback device.  However, not all modern CD players have
1874 this filter, and very few PC CD drives have it; playing pre-emphasised
1875 audio without the correct de-emphasis filter results in audio that sounds harsh
1876 and is far from what its creators intended.
1878 With the
1879 .B deemph
1880 effect, it is possible to apply the necessary de-emphasis to audio that
1881 has been extracted from a pre-emphasised CD, and then either burn the
1882 de-emphasised audio to a new CD (which will then play correctly on any
1883 CD player), or simply play the correctly de-emphasised audio files on the
1884 PC.  For example:
1886    sox track1.wav track1-deemph.wav deemph
1888 and then burn track1-deemph.wav to CD, or
1890    play track1-deemph.wav
1892 or simply
1894    play track1.wav deemph
1896 The de-emphasis filter is implemented as a biquad; its maximum deviation
1897 from the ideal response is only 0\*d06dB (up to 20kHz).
1899 This effect supports the \fB\-\-plot\fR global option.
1901 See also the \fBbass\fR and \fBtreble\fR shelving equalisation effects.
1903 \fBdelay\fR {\fIlength\fR}
1904 Delay one or more audio channels.
1905 .I length
1906 can specify a time or, if appended with an `s', a number of samples.
1907 Do not specify both time and samples delays in the same command.
1908 For example,
1909 .B delay 1\*d5 0 0\*d5
1910 delays the first channel by 1\*d5 seconds, the third channel by 0\*d5
1911 seconds, and leaves the second channel (and any other channels that may be
1912 present) un-delayed.
1913 The following (one long) command plays a chime sound:
1915 .ne 3
1916    play \-n synth \-j 3 sin %3 sin %\-2 sin %\-5 sin %\-9 \\
1917         sin %\-14 sin %\-21 fade h .01 2 1.5 delay \\
1918         1.3 1 .76 .54 .27 remix \- fade h 0 2.7 2.5 norm \-1
1920 and this plays a guitar chord:
1922 .ne 2
1923    play \-n synth pl G2 pl B2 pl D3 pl G3 pl D4 pl G4 \\
1924         delay 0 .05 .1 .15 .2 .25 remix \- fade 0 4 .1 norm \-1
1927 \fBdither\fR [\fB\-a\fR] [\fB\-S\fR\^|\^\fB\-s\fR\^|\^\fB\-f \fIfilter\fR]
1928 Apply dithering to the audio.
1929 Dithering deliberately adds a small amount of noise to the signal in
1930 order to mask audible quantization effects that can occur if the output
1931 sample size is less than 24 bits.  With no options, this effect will
1932 add triangular (TPDF) white noise.  Noise-shaping (only for certain
1933 sample rates) can be selected with
1934 .BR \-s .
1935 With the
1936 .B \-f
1937 option, it is possible to select a particular noise-shaping filter from
1938 the following list: lipshitz, f-weighted, modified-e-weighted,
1939 improved-e-weighted, gesemann, shibata, low-shibata, high-shibata.  Note
1940 that most filter types are available only with 44100Hz sample rate.  The
1941 filter types are distinguished by the following properties: audibility
1942 of noise, level of (inaudible, but in some circumstances, otherwise
1943 problematic) shaped high frequency noise, and processing speed.
1945 See http://sox.sourceforge.net/SoX/NoiseShaping for graphs of the different
1946 noise-shaping curves.
1949 .B \-S
1950 option selects a slightly `sloped' TPDF, biased towards higher
1951 frequencies.  It can be used at any sampling rate but below \(~~22k,
1952 plain TPDF is probably better, and above \(~~ 37k, noise-shaped
1953 is probably better.
1956 .B \-a
1957 option enables a mode where dithering (and noise-shaping if applicable)
1958 are automatically enabled only when needed.  The most likely use for
1959 this is when applying fade in or out to an already dithered file, so
1960 that the redithering applies only to the faded portions.  However, auto
1961 dithering is not fool-proof, so the fades should be carefully checked
1962 for any noise modulation; if this occurs, then either re-dither the whole
1963 file, or use
1964 .BR trim ,
1965 .BR fade ,
1966 and concatencate.
1968 If the SoX global option
1969 .B \-R
1970 option is not given, then the pseudo-random number generator used to
1971 generate the white noise will be `reseeded', i.e. the generated noise
1972 will be different between invocations.
1974 This effect should not be followed by any other effect that
1975 affects the audio.
1977 See also the `Dither' section above.
1979 \fBearwax\fR
1980 Makes audio easier to listen to on headphones.
1981 Adds `cues' to 44\*d1kHz stereo (i.e. audio CD format) audio so that
1982 when listened to on headphones the stereo image is
1983 moved from inside
1984 your head (standard for headphones) to outside and in front of the
1985 listener (standard for speakers).  See
1986 http://www.geocities.com/beinges
1987 for a full explanation.
1989 \fBecho \fIgain-in gain-out\fR <\fIdelay decay\fR>
1990 Add echoing to the audio.
1991 Echoes are reflected sound and can occur naturally amongst mountains
1992 (and sometimes large buildings) when talking or shouting; digital echo
1993 effects emulate this behaviour and are often used to help fill
1994 out the sound of a single instrument or vocal.  The time difference
1995 between the original signal and the reflection is the `delay' (time),
1996 and the loudness of the reflected signal is the `decay'.  Multiple echoes
1997 can have different delays and decays.
1999 Each given
2000 .I "delay decay"
2001 pair gives the delay in milliseconds
2002 and the decay (relative to gain-in) of that echo.
2003 Gain-out is the volume of the output.
2004 For example:
2005 This will make it sound as if there are twice as many instruments as are
2006 actually playing:
2008    play lead.aiff echo 0.8 0.88 60 0.4
2010 If the delay is very short, then it sound like a (metallic) robot playing
2011 music:
2013    play lead.aiff echo 0.8 0.88 6 0.4
2015 A longer delay will sound like an open air concert in the mountains:
2017    play lead.aiff echo 0.8 0.9 1000 0.3
2019 One mountain more, and:
2021    play lead.aiff echo 0.8 0.9 1000 0.3 1800 0.25
2024 \fBechos \fIgain-in gain-out\fR <\fIdelay decay\fR>
2025 Add a sequence of echoes to the audio.
2026 Each
2027 .I "delay decay"
2028 pair gives the delay in milliseconds
2029 and the decay (relative to gain-in) of that echo.
2030 Gain-out is the volume of the output.
2032 Like the echo effect, echos stand for `ECHO in Sequel', that is the first echos
2033 takes the input, the second the input and the first echos, the third the input
2034 and the first and the second echos, ... and so on.
2035 Care should be taken using many echos; a single echos
2036 has the same effect as a single echo.
2038 The sample will be bounced twice in symmetric echos:
2040    play lead.aiff echos 0.8 0.7 700 0.25 700 0.3
2042 The sample will be bounced twice in asymmetric echos:
2044    play lead.aiff echos 0.8 0.7 700 0.25 900 0.3
2046 The sample will sound as if played in a garage:
2048    play lead.aiff echos 0.8 0.7 40 0.25 63 0.3
2051 \fBequalizer \fIfrequency\fR[\fBk\fR]\fI width\fR[\fBq\fR\^|\^\fBo\fR\^|\^\fBh\fR\^|\^\fBk\fR] \fIgain\fR
2052 Apply a two-pole peaking equalisation (EQ) filter.
2053 With this filter, the signal-level at and around a selected frequency
2054 can be increased or decreased, whilst (unlike band-pass and band-reject
2055 filters) that at all other frequencies is unchanged.
2057 \fIfrequency\fR gives the filter's central frequency in Hz,
2058 \fIwidth\fR, the band-width,
2059 and \fIgain\fR the required gain
2060 or attenuation in dB.
2061 Beware of
2062 .B Clipping
2063 when using a positive \fIgain\fR.
2065 In order to produce complex equalisation curves, this effect
2066 can be given several times, each with a different central frequency.
2068 The filter is described in detail in [1].
2070 This effect supports the \fB\-\-plot\fR global option.
2072 See also \fBbass\fR and \fBtreble\fR for shelving equalisation effects.
2074 \fBfade\fR [\fItype\fR] \fIfade-in-length\fR [\fIstop-time\fR [\fIfade-out-length\fR]]
2075 Apply a fade effect to the beginning, end, or both of the audio.
2077 An optional \fItype\fR can be specified to select the shape of the fade
2078 curve:
2079 \fBq\fR for quarter of a sine wave, \fBh\fR for half a sine
2080 wave, \fBt\fR for linear (`triangular') slope, \fBl\fR for logarithmic,
2081 and \fBp\fR for inverted parabola.  The default is logarithmic.
2083 A fade-in starts from the first sample and ramps the signal level from 0 to full volume over \fIfade-in-length\fR seconds.  Specify 0 seconds if no fade-in is wanted.
2085 For fade-outs, the audio will be truncated at
2086 .I stop-time
2088 the signal level will be ramped from full volume down to 0 starting at
2089 \fIfade-out-length\fR seconds before the \fIstop-time\fR.  If
2090 .I fade-out-length
2091 is not specified, it defaults to the same value as
2092 \fIfade-in-length\fR.
2093 No fade-out is performed if
2094 .I stop-time
2095 is not specified.
2096 If the file length can be determined from the input file header and length-changing effects are not in effect, then \fB0\fR may be specified for
2097 .I stop-time
2098 to indicate the usual case of a fade-out that ends at the end of the input
2099 audio stream.
2101 All times can be specified in either periods of time or sample counts.
2102 To specify time periods use the format hh:mm:ss.frac format.  To specify
2103 using sample counts, specify the number of samples and append the letter `s'
2104 to the sample count (for example `8000s').
2106 See also the
2107 .B splice
2108 effect.
2110 \fBfir\fR [\fIcoefs-file\fR\^|\^\fIcoefs\fR]
2111 Use SoX's FFT convolution engine with given FIR filter
2112 coefficients.
2113 If a single argument is given then this is treated as the name of a file
2114 containing the filter coefficients (white-space separated; may contain
2115 `#' comments).  If the given filename is `\-', or if no argument is
2116 given, then the coefficients are read from the `standard input' (stdin);
2117 otherwise, coefficients may be given on the command line.
2118 Examples:
2120    sox infile outfile fir 0.0195 \-0.082 0.234 0.891 \-0.145 0.043
2123    sox infile outfile fir coefs.txt
2125 with coefs.txt containing
2127    # HP filter
2128    # freq=10000
2129      1.2311233052619888e-01
2130     \-4.4777096106211783e-01
2131      5.1031563346705155e-01
2132     \-6.6502926320995331e-02
2133    ...
2136 \fBflanger\fR [\fIdelay depth regen width speed shape phase interp\fR]
2137 Apply a flanging effect to the audio.
2138 See [3] for a detailed description of flanging.
2140 All parameters are optional (right to left).
2141 .ne 15
2143 center;
2144 cI cI cI lI
2145 cI c c l.
2146 \       Range   Default Description
2147 delay   0 \- 30 0       Base delay in milliseconds.
2148 depth   0 \- 10 2       Added swept delay in milliseconds.
2149 regen   \-95 \- 95      0       T{
2151 Percentage regeneration (delayed signal feedback).
2153 width   0 \- 100        71      T{
2155 Percentage of delayed signal mixed with original.
2157 speed   0\*d1 \- 10     0\*d5   Sweeps per second (Hz).
2158 shape   \       sin     Swept wave shape: \fBsine\fR\^|\^\fBtriangle\fR.
2159 phase   0 \- 100        25      T{
2161 Swept wave percentage phase-shift for multi-channel (e.g. stereo) flange;
2162 0 = 100 = same phase on each channel.
2164 interp  \       lin     T{
2166 Digital delay-line interpolation: \fBlinear\fR\^|\^\fBquadratic\fR.
2171 \fBgain \fR[\fB\-e\fR\^|\^\fB\-B\fR\^|\^\fB\-b\fR\^|\^\fB\-r\fR] [\fB\-n\fR] [\fB\-l\fR\^|\^\fB\-h\fR] [\fIgain-dB\fR]
2172 Apply amplification or attenuation to the audio signal, or, in some
2173 cases, to some of its channels.
2174 Note that use of any of
2175 .BR \-e ,
2176 .BR \-B ,
2177 .BR \-b ,
2178 .BR \-r ,
2180 .B \-n
2181 requires temporary file space to store the audio to be processed, so may
2182 be unsuitable for use with `streamed' audio.
2184 Without other options,
2185 .I gain-dB
2186 is used to adjust the signal power level by the given number of dB:
2187 positive amplifies (beware of Clipping), negative attenuates.  With
2188 other options, the
2189 .I gain-dB
2190 amplification or attenuation is (logically) applied after the processing due to those options.
2192 Given the
2193 .B \-e
2194 option, the levels of the audio channels of a multi-channel file are `equalised', i.e.
2195 gain is applied to all channels other than that with the highest peak
2196 level, such that all channels attain the same peak level
2197 (but, without also giving
2198 .BR \-n ,
2199 the audio is not `normalised').
2202 .B \-B
2203 (balance) option is similar to
2204 .BR \-e ,
2205 but with
2206 .BR \-B,
2207 the RMS level is used instead of the peak level.
2208 .B \-B
2209 might be used to correct stereo imbalance caused by an imperfect record
2210 turntable cartridge.   Note
2211 that unlike
2212 .BR \-e ,
2213 .B \-B
2214 might cause some clipping.
2216 .B \-b
2217 is similar to
2218 .B \-B
2219 but has clipping protection, i.e.  if necessary to prevent clipping
2220 whilst balancing, attenuation is applied to all channels.
2221 Note, however, that in conjunction with
2222 .BR \-n ,
2223 .B \-B
2225 .B \-b
2226 are synonymous.
2229 .B \-r
2230 option is used in conjunction with a prior invocation of
2231 .B gain
2232 with the
2233 .B \-h
2234 option\*msee below for details.
2237 .B \-n
2238 option normalises the audio to 0dB FSD; it is often used in conjunction with a negative
2239 .I gain-dB
2240 to the effect that the audio is normalised to a given level below 0dB.
2241 For example,
2243    sox infile outfile gain \-n
2245 normalises to 0dB, and
2247    sox infile outfile gain \-n \-3
2249 normalises to \-3dB.
2252 .B \-l
2253 option invokes a simple limiter, e.g.
2255    sox infile outfile gain \-l 6
2257 will apply 6dB of gain but never clip.  Note that limiting more than a
2258 few dBs more than occasionally (in a piece of audio) is not recommended
2259 as it can cause audible distortion.
2260 See the
2261 .B compand
2262 effect for a more capable limiter.
2265 .B \-h
2266 option is used to apply gain to provide head-room for subsequent
2267 processing.  For example, with
2269    sox infile outfile gain \-h bass +6
2271 6dB of attenuation will be applied prior to the bass boosting effect
2272 thus ensuring that it will not clip.  Of course, with bass, it is
2273 obvious how much headroom will be needed, but with other effects (e.g.
2274 rate, dither) it is not always as clear.  Another advantage of using
2275 \fBgain \-h\fR rather than an explicit attenuation, is that if the
2276 headroom is not used by subsequent effects, it can be reclaimed with
2277 \fBgain \-r\fR, for example:
2279    sox infile outfile gain \-h bass +6 rate 44100 gain \-r
2281 The above effects chain guarantees never to clip nor amplify;
2282 it attenuates if necessary to prevent clipping, but by only as
2283 much as is needed to do so.
2285 Output formatting (dithering and bit-depth reduction) also requires
2286 headroom (which cannot be `reclaimed'), e.g.
2288    sox infile outfile gain \-h bass +6 rate 44100 gain \-rh dither
2290 Here, the second
2291 .B gain
2292 invocation, reclaims as much of the headroom as it can from the
2293 preceding effects, but retains as much headroom as is needed for
2294 subsequent processing.
2295 The SoX global option
2296 .B \-G
2297 can be given to automatically invoke \fBgain \-h\fR and \fBgain \-r\fR.
2299 See also the
2300 .B norm
2302 .B vol
2303 effects.
2305 \fBhighpass\fR\^|\^\fBlowpass\fR [\fB\-1\fR|\fB\-2\fR] \fIfrequency\fR[\fBk\fR]\fR [\fRwidth\fR[\fBq\fR\^|\^\fBo\fR\^|\^\fBh\fR\^|\^\fBk\fR]]
2306 Apply a high-pass or low-pass filter with 3dB point \fIfrequency\fR.
2307 The filter can be either single-pole (with
2308 .BR \-1 ),
2309 or double-pole (the default, or with
2310 .BR \-2 ).
2311 .I width
2312 applies only to double-pole filters;
2313 the default is Q = 0\*d707 and gives a Butterworth response.  The filters
2314 roll off at 6dB per pole per octave (20dB per pole per decade).  The
2315 double-pole filters are described in detail in [1].
2317 These effects support the \fB\-\-plot\fR global option.
2319 See also \fBsinc\fR for filters with a steeper roll-off.
2321 \fBladspa\fR \fBmodule\fR [\fBplugin\fR] [\fBargument\fR...]
2322 Apply a LADSPA [5] (Linux Audio Developer's Simple Plugin API) plugin.
2323 Despite the name, LADSPA is not Linux-specific, and a wide range of
2324 effects is available as LADSPA plugins, such as cmt [6] (the Computer
2325 Music Toolkit) and Steve Harris's plugin collection [7]. The first
2326 argument is the plugin module, the second the name of the plugin (a
2327 module can contain more than one plugin) and any other arguments are
2328 for the control ports of the plugin. Missing arguments are supplied by
2329 default values if possible. Only plugins with at most one audio input
2330 and one audio output port can be used.  If found, the environment variable
2331 LADSPA_PATH will be used as search path for plugins.
2333 \fBloudness\fR [\fIgain\fR [\fIreference\fR]]
2334 Loudness control\*msimilar to the
2335 .B gain
2336 effect, but provides equalisation for the human auditory system.  See
2337 http://en.wikipedia.org/wiki/Loudness for a detailed description of
2338 loudness.  The gain is adjusted by the given
2339 .I gain
2340 parameter (usually negative) and the signal equalised according to ISO
2341 226 w.r.t. a reference level of 65dB, though an alternative
2342 .I reference
2343 level may be given if the original audio has been equalised for some
2344 other optimal level.
2345 A default gain of \-10dB is used if a
2346 .I gain
2347 value is not given.
2349 See also the
2350 .B gain
2351 effect.
2353 \fBlowpass\fR [\fB\-1\fR|\fB\-2\fR] \fIfrequency\fR[\fBk\fR]\fR [\fRwidth\fR[\fBq\fR\^|\^\fBo\fR\^|\^\fBh\fR\^|\^\fBk\fR]]
2354 Apply a low-pass filter.
2355 See the description of the \fBhighpass\fR effect for details.
2357 \fBmcompand\fR \(dq\fIattack1\fB,\fIdecay1\fR{\fB,\fIattack2\fB,\fIdecay2\fR}
2358 [\fIsoft-knee-dB\fB:\fR]\fIin-dB1\fR[\fB,\fIout-dB1\fR]{\fB,\fIin-dB2\fB,\fIout-dB2\fR}
2360 [\fIgain\fR [\fIinitial-volume-dB\fR [\fIdelay\fR]]]\(dq {\fIcrossover-freq\fR[\fBk\fR] \(dqattack1,...\(dq}
2362 The multi-band compander is similar to the single-band compander but the
2363 audio is first divided into bands using Linkwitz-Riley cross-over filters
2364 and a separately specifiable compander run on each band.  See the
2365 \fBcompand\fR effect for the definition of its parameters.  Compand
2366 parameters are specified between double quotes and the crossover
2367 frequency for that band is given by \fIcrossover-freq\fR; these can be
2368 repeated to create multiple bands.
2370 For example, the following (one long) command shows how multi-band
2371 companding is typically used in FM radio:
2373 .ne 8
2374    play track1.wav gain \-3 sinc 8000\- 29 100 mcompand \\
2375         \(dq0.005,0.1 \-47,\-40,\-34,\-34,\-17,\-33\(dq 100 \\
2376         \(dq0.003,0.05 \-47,\-40,\-34,\-34,\-17,\-33\(dq 400 \\
2377         \(dq0.000625,0.0125 \-47,\-40,\-34,\-34,\-15,\-33\(dq 1600 \\
2378         \(dq0.0001,0.025 \-47,\-40,\-34,\-34,\-31,\-31,\-0,\-30\(dq 6400 \\
2379         \(dq0,0.025 \-38,\-31,\-28,\-28,\-0,\-25\(dq \\
2380         gain 15 highpass 22 highpass 22 sinc \-n 255 \-b 16 \-17500 \\
2381         gain 9 lowpass \-1 17801
2383 The audio file is played with a simulated FM radio sound (or broadcast
2384 signal condition if the lowpass filter at the end is skipped).
2385 Note that the pipeline is set up with US-style 75us pre-emphasis.
2387 See also
2388 .B compand
2389 for a single-band companding effect.
2391 \fBmixer\fR [ \fB\-l\fR\^|\^\fB\-r\fR\^|\^\fB\-f\fR\^|\^\fB\-b\fR\^|\^\fB\-1\fR\^|\^\fB\-2\fR\^|\^\fB\-3\fR\^|\^\fB\-4\fR\^|\^\fIn\fR{\fB,\fIn\fR} ]
2392 Reduce the number of audio channels by mixing or selecting channels,
2393 or increase the number of channels by duplicating channels.
2394 Note: this effect operates on the audio
2395 .I channels
2396 within the SoX effects processing chain; it should not be confused with the
2397 .B \-m
2398 global option (where multiple
2399 .I files
2400 are mix-combined before entering the effects chain).
2402 When reducing the number of channels it is possible to
2403 use the \fB\-l\fR, \fB\-r\fR, \fB\-f\fR, \fB\-b\fR,
2404 \fB\-1\fR, \fB\-2\fR, \fB\-3\fR, \fB\-4\fR, options to select only
2405 the left, right, front, back channel(s) or specific channel
2406 for the output instead of averaging the channels.
2407 The \fB\-l\fR, and \fB\-r\fR options will do averaging
2408 in quad-channel files so select the exact channel to prevent this.
2411 .B mixer
2412 effect can also be invoked with up to 16
2413 numbers, separated by commas, which specify the proportion (0 = 0% and 1 = 100%)
2414 of each input channel that is to be mixed into each output channel.
2415 In two-channel mode, 4 numbers are given: l \*(RA l, l \*(RA r, r \*(RA l, and r \*(RA r,
2416 respectively.
2417 In four-channel mode, the first 4 numbers give the proportions for the
2418 left-front output channel, as follows: lf \*(RA lf, rf \*(RA lf, lb \*(RA lf, and
2419 rb \*(RA rf.
2420 The next 4 give the right-front output in the same order, then
2421 left-back and right-back.
2423 It is also possible to use the 16 numbers to expand or reduce the
2424 channel count; just specify 0 for unused channels.
2426 Finally, certain reduced combination of numbers can be specified
2427 for certain input/output channel combinations.
2428 .ne 7
2430 center;
2431 cI cI cI lI
2432 c c c l .
2433 In Ch   Out Ch  Num     Mappings
2434 2       1       2       l \*(RA l, r \*(RA l
2435 2       2       1       adjust balance
2436 4       1       4       lf \*(RA l, rf \*(RA l, lb \*(RA l, rb \*(RA l
2437 4       2       2       lf \*(RA l&rf \*(RA r, lb \*(RA l&rb \*(RA r
2438 4       4       1       adjust balance
2439 4       4       2       front balance, back balance
2443 See also
2444 .B remix
2445 for a mixing effect that handles any number of channels.
2447 \fBnoiseprof\fR [\fIprofile-file\fR]
2448 Calculate a profile of the audio for use in noise reduction.  See the
2449 description of the \fBnoisered\fR effect for details.
2451 \fBnoisered\fR [\fIprofile-file\fR [\fIamount\fR]]
2452 Reduce noise in the audio signal by profiling and filtering.  This
2453 effect is moderately effective at removing consistent background noise
2454 such as hiss or hum.  To use it, first run SoX with the \fBnoiseprof\fR
2455 effect on a section of audio that ideally would contain silence but in
2456 fact contains noise\*msuch sections are typically found at the beginning
2457 or the end of a recording.  \fBnoiseprof\fR will write out a noise
2458 profile to \fIprofile-file\fR, or to stdout if no \fIprofile-file\fR or
2459 if `\-' is given.  E.g.
2461    sox speech.wav \-n trim 0 1.5 noiseprof speech.noise-profile
2463 To actually remove the noise, run SoX again, this time with the \fBnoisered\fR
2464 effect;
2465 .B noisered
2466 will reduce noise according to a noise profile (which was generated by
2467 .BR noiseprof ),
2468 from
2469 .IR profile-file ,
2470 or from stdin if no \fIprofile-file\fR or if `\-' is given.  E.g.
2472    sox speech.wav cleaned.wav noisered speech.noise-profile 0.3
2474 How much noise should be removed is specified by
2475 .IR amount \*ma
2476 number between 0 and 1 with a default of 0\*d5.  Higher numbers will
2477 remove more noise but present a greater likelihood of removing wanted
2478 components of the audio signal.  Before replacing an original recording
2479 with a noise-reduced version, experiment with different
2480 .I amount
2481 values to find the optimal one for your audio; use headphones to check
2482 that you are happy with the results, paying particular attention to quieter
2483 sections of the audio.
2485 On most systems, the two stages\*mprofiling and reduction\*mcan be combined
2486 using a pipe, e.g.
2488    sox noisy.wav \-n trim 0 1 noiseprof | play noisy.wav noisered
2491 \fBnorm\fR [\fIdB-level\fR]
2492 Normalise the audio.
2493 .B norm
2494 is just an alias for \fBgain \-n\fR; see the
2495 .B gain
2496 effect for details.
2498 Note that \fBnorm\fR's
2499 .B \-i
2501 .B \-b
2502 options are deprecated (having been superseded by \fBgain \-en\fR and
2503 \fBgain \-B\fR respectively) and will be removed in a future release.
2505 \fBoops\fR
2506 Out Of Phase Stereo effect.
2507 Mixes stereo to twin-mono where each mono channel contains the
2508 difference between the left and right stereo channels.
2509 This is sometimes known as the `karaoke' effect as it often has the effect
2510 of removing most or all of the vocals from a recording.
2512 \fBoverdrive\fR [\fIgain\fR(20) [\fIcolour\fR(20)]]
2513 Non linear distortion.
2514 The \fIcolour\fR parameter controls the amount of even harmonic content
2515 in the over-driven output.
2517 \fBpad\fR { \fIlength\fR[\fB@\fIposition\fR] }
2518 Pad the audio with silence, at the beginning, the end, or any
2519 specified points through the audio.
2520 Both
2521 .I length
2523 .I position
2524 can specify a time or, if appended with an `s', a number of samples.
2525 .I length
2526 is the amount of silence to insert and
2527 .I position
2528 the position in the input audio stream at which to insert it.
2529 Any number of lengths and positions may be specified, provided that
2530 a specified position is not less that the previous one.
2531 .I position
2532 is optional for the first and last lengths specified and
2533 if omitted correspond to the beginning and the end of the audio respectively.
2534 For example,
2535 .B pad 1\*d5 1\*d5
2536 adds 1\*d5 seconds of silence padding at each end of the audio, whilst
2537 .B pad 4000s@3:00
2538 inserts 4000 samples of silence 3 minutes into the audio.
2539 If silence is wanted only at the end of the audio, specify either the end
2540 position or specify a zero-length pad at the start.
2542 See also
2543 .B delay
2544 for an effect that can add silence at the beginning of
2545 the audio on a channel-by-channel basis.
2547 \fBphaser \fIgain-in gain-out delay decay speed\fR [\fB\-s\fR\^|\^\fB\-t\fR]
2548 Add a phasing effect to the audio.
2549 See [3] for a detailed description of phasing.
2551 delay/decay/speed gives the delay in milliseconds
2552 and the decay (relative to gain-in) with a modulation
2553 speed in Hz.
2554 The modulation is either sinusoidal (\fB\-s\fR) \*mpreferable for multiple
2555 instruments, or triangular
2556 (\fB\-t\fR) \*mgives single instruments a sharper phasing effect.
2557 The decay should be less than 0\*d5 to avoid
2558 feedback, and usually no less than 0\*d1.  Gain-out is the volume of the output.
2560 For example:
2562    play snare.flac phaser 0.8 0.74 3 0.4 0.5 \-t
2564 Gentler:
2566    play snare.flac phaser 0.9 0.85 4 0.23 1.3 \-s
2568 A popular sound:
2570    play snare.flac phaser 0.89 0.85 1 0.24 2 \-t
2572 More severe:
2574    play snare.flac phaser 0.6 0.66 3 0.6 2 \-t
2577 \fBpitch \fR[\fB\-q\fR] \fIshift\fR [\fIsegment\fR [\fIsearch\fR [\fIoverlap\fR]]]
2578 Change the audio pitch (but not tempo).
2580 .I shift
2581 gives the pitch shift as positive or negative `cents' (i.e. 100ths of a
2582 semitone).  See the
2583 .B tempo
2584 effect for a description of the other parameters.
2586 See also the
2587 .B speed
2589 .B tempo
2590 effects.
2592 \fBrate\fR [\fB\-q\fR\^|\^\fB\-l\fR\^|\^\fB\-m\fR\^|\^\fB\-h\fR\^|\^\fB\-v\fR] [override-options] \fIRATE\fR[\fBk\fR]
2593 Change the audio sampling rate (i.e. resample the audio) to any given
2594 .I RATE
2595 (even non-integer if this is supported by the output file format)
2596 using a quality level defined as follows:
2597 .ne 10
2599 center;
2600 cI cI2w9 cI2w6 cIw6 lIw17
2601 cB c c c l.
2602 \       Quality T{
2604 Band-width
2605 T}      Rej dB  T{
2607 Typical Use
2609 \-q     T{
2611 quick
2612 T}      n/a     T{
2614 \(~=30 @ \ Fs/4
2615 T}      T{
2617 playback on ancient hardware
2619 \-l     low     80%     100     T{
2621 playback on old hardware
2623 \-m     medium  95%     100     T{
2625 audio playback
2627 \-h     high    95%     125     T{
2629 16-bit mastering (use with dither)
2631 \-v     T{
2633 very high
2634 T}      95%     175     24-bit mastering
2638 where
2639 .I Band-width
2640 is the percentage of the audio frequency band that is preserved and
2641 .I Rej dB
2642 is the level of noise rejection.  Increasing levels of resampling
2643 quality come at the expense of increasing amounts of time to process the
2644 audio.  If no quality option is given, the quality level used is `high'.
2646 The `quick' algorithm uses cubic interpolation; all others use
2647 band-limited interpolation.  By default, all algorithms have
2648 a `linear' phase response; for `medium', `high' and
2649 `very high', the phase response is configurable (see below).
2652 .B rate
2653 effect is invoked automatically if SoX's \fB\-r\fR option specifies a
2654 rate that is different to that of the input file(s).  Alternatively, if
2655 this effect is given explicitly, then SoX's
2656 .B \-r
2657 option need not be given.  For example, the following two commands are
2658 equivalent:
2660 .ne 2
2661    sox input.wav \-r 48k output.wav bass \-3
2662    sox input.wav        output.wav bass \-3 rate 48k
2664 though the second command is more flexible as it allows
2665 .B rate
2666 options to be given, and allows the effects to be ordered arbitrarily.
2668 center;
2669 c8 c8 c.
2670 *       *       *
2674 Warning: technically detailed discussion follows.
2676 The simple quality selection described above provides settings that
2677 satisfy the needs of the vast majority of resampling tasks.
2678 Occasionally, however, it may be desirable to fine-tune the resampler's
2679 filter response; this can be achieved using
2680 .IR override\ options ,
2681 as detailed in the following table:
2682 .ne 6
2684 center;
2685 lB lw52.
2686 \-M/\-I/\-L     Phase response = minimum/intermediate/linear
2687 \-s     Steep filter (band-width = 99%)
2688 \-a     Allow aliasing/imaging above the pass-band
2689 \-b\ 74\-99\*d7 Any band-width %
2690 \-p\ 0\-100     T{
2692 Any phase response (0 = minimum, 25 = intermediate, 50 = linear, 100 = maximum)
2697 N.B.  Override options can not be used with the `quick' or `low'
2698 quality algorithms.
2700 All resamplers use filters that can sometimes create `echo' (a.k.a.
2701 `ringing') artefacts with transient signals such as those that occur
2702 with `finger snaps' or other highly percussive sounds.  Such artefacts are
2703 much more noticeable to the human ear if they occur before the transient
2704 (`pre-echo') than if they occur after it (`post-echo').  Note that
2705 frequency of any such artefacts is related to the smaller of the
2706 original and new sampling rates but that if this is at least 44\*d1kHz,
2707 then the artefacts will lie outside the range of human hearing.
2709 A phase response setting may be used to control the distribution of any
2710 transient echo between
2711 `pre' and `post': with minimum phase, there is no pre-echo but the
2712 longest post-echo; with linear phase, pre and post echo are in equal
2713 amounts (in signal terms, but not audibility terms); the intermediate
2714 phase setting attempts to find the best compromise by selecting a small
2715 length (and level) of pre-echo and a medium lengthed post-echo.
2717 Minimum, intermediate, or linear phase response is selected using the
2718 .BR \-M ,
2719 .BR \-I ,
2721 .B \-L
2722 option; a custom phase response can be created with the
2723 .B \-p
2724 option.  Note that phase responses between `linear' and `maximum'
2725 (greater than 50) are rarely useful.
2727 A resampler's band-width setting determines how much of the frequency
2728 content of the original signal (w.r.t. the original sample rate when
2729 up-sampling, or the new sample rate when down-sampling) is preserved
2730 during conversion.  The term `pass-band' is used to refer to all frequencies
2731 up to the band-width point (e.g. for 44\*d1kHz sampling rate, and a
2732 resampling band-width of 95%, the pass-band represents frequencies from
2733 0Hz (D.C.) to circa 21kHz).  Increasing the resampler's band-width
2734 results in a slower conversion and can increase transient echo
2735 artefacts (and vice versa).
2738 .B \-s
2739 `steep filter' option changes resampling band-width from the default 95%
2740 (based on the 3dB point), to 99%.  The
2741 .B \-b
2742 option allows the band-width to be set to any value in the range
2743 74\-99\*d7 %, but note that band-width values greater than 99% are not
2744 recommended for normal use as they can cause excessive transient echo.
2746 If the
2747 .B \-a
2748 option is given, then aliasing/imaging above the pass-band is allowed.  For
2749 example, with 44\*d1kHz sampling rate, and a
2750 resampling band-width of 95%, this means that frequency content above
2751 21kHz can be distorted; however, since this is above the pass-band (i.e.
2752 above the highest frequency of interest/audibility), this may not be a
2753 problem.  The benefits of allowing aliasing/imaging are reduced processing time,
2754 and reduced (by almost half) transient echo artefacts.
2755 Note that if this option is given, then
2756 the minimum band-width allowable with
2757 .B \-b
2758 increases to 85%.
2760 Examples:
2762    sox input.wav \-b 16 output.wav rate \-s \-a 44100 dither \-s
2764 default (high) quality resampling; overrides: steep filter, allow
2765 aliasing; to 44\*d1kHz sample rate; noise-shaped dither to 16-bit WAV
2766 file.
2768    sox input.wav \-b 24 output.aiff rate \-v \-I \-b 90 48k
2770 very high quality resampling; overrides: intermediate phase, band-width 90%;
2771 to 48k sample rate; store output to 24-bit AIFF file.
2773 center;
2774 c8 c8 c.
2775 *       *       *
2780 .BR pitch ,
2781 .B speed
2783 .B tempo
2784 effects all use the
2785 .B rate
2786 effect at their core.
2788 \fBremix\fR [\fB\-a\fR\^|\^\fB\-m\fR\^|\^\fB\-p\fR] <\fIout-spec\fR>
2789 \fIout-spec\fR  = \fIin-spec\fR{\fB,\fIin-spec\fR} | \fB0\fR
2791 \fIin-spec\fR   = [\fIin-chan\fR]\^[\fB\-\fR[\fIin-chan2\fR]]\^[\fIvol-spec\fR]
2793 \fIvol-spec\fR  = \fBp\fR\^|\^\fBi\fR\^|\^\fBv\^\fR[\fIvolume\fR]
2796 Select and mix input audio channels into output audio channels.  Each output
2797 channel is specified, in turn, by a given \fIout-spec\fR: a list of
2798 contributing input channels and volume specifications.
2800 Note that this effect operates on the audio
2801 .I channels
2802 within the SoX effects processing chain; it should not be confused with the
2803 .B \-m
2804 global option (where multiple
2805 .I files
2806 are mix-combined before entering the effects chain).
2809 .I out-spec
2810 contains comma-separated input channel-numbers and hyphen-delimited
2811 channel-number ranges; alternatively,
2812 .B 0
2813 may be given to create a silent output channel.  For example,
2815    sox input.wav output.wav remix 6 7 8 0
2817 creates an output file with four channels, where channels 1, 2, and 3 are
2818 copies of channels 6, 7, and 8 in the input file, and channel 4 is silent.
2819 Whereas
2821    sox input.wav output.wav remix 1-3,7 3
2823 creates a (somewhat bizarre) stereo output file where the left channel
2824 is a mix-down of input channels 1, 2, 3, and 7, and the right channel is
2825 a copy of input channel 3.
2827 Where a range of channels is specified, the channel numbers to the left and
2828 right of the hyphen are optional and default to 1 and to the number of input
2829 channels respectively. Thus
2831    sox input.wav output.wav remix \-
2833 performs a mix-down of all input channels to mono.
2835 By default, where an output channel is mixed from multiple (n) input
2836 channels, each input channel will be scaled by a factor of \(S1/\s-2n\s+2.
2837 Custom mixing volumes can be set by following a given input channel or range
2838 of input channels with a \fIvol-spec\fR (volume specification).
2839 This is one of the letters \fBp\fR, \fBi\fR, or \fBv\fR,
2840 followed by a volume number, the meaning of which depends on the given
2841 letter and is defined as follows:
2843 center;
2844 lI lI lI
2845 c l l.
2846 Letter  Volume number   Notes
2847 p       power adjust in dB      0 = no change
2848 i       power adjust in dB      T{
2850 As `p', but invert the audio
2852 v       voltage multiplier      T{
2854 1 = no change, 0\*d5 \(~= 6dB attenuation, 2 \(~= 6dB gain, \-1 = invert
2859 If an
2860 .I out-spec
2861 includes at least one
2862 .I vol-spec
2863 then, by default, \(S1/\s-2n\s+2 scaling is not applied to any other channels in the
2864 same out-spec (though may be in other out-specs).
2865 The \-a (automatic)
2866 option however, can be given to retain the automatic scaling in this
2867 case.  For example,
2869    sox input.wav output.wav remix 1,2 3,4v0.8
2871 results in channel level multipliers of 0\*d5,0\*d5 1,0\*d8, whereas
2873    sox input.wav output.wav remix \-a 1,2 3,4v0.8
2875 results in channel level multipliers of 0\*d5,0\*d5 0\*d5,0\*d8.
2877 The \-m (manual) option disables all automatic volume adjustments, so
2879    sox input.wav output.wav remix \-m 1,2 3,4v0.8
2881 results in channel level multipliers of 1,1 1,0\*d8.
2883 The volume number is optional and omitting it corresponds to no volume
2884 change; however, the only case in which this is useful is in conjunction
2885 with
2886 .BR i .
2887 For example, if
2888 .I input.wav
2889 is stereo, then
2891    sox input.wav output.wav remix 1,2i
2893 is a mono equivalent of the
2894 .B oops
2895 effect.
2897 If the \fB\-p\fR option is given, then any automatic \(S1/\s-2n\s+2 scaling
2898 is replaced by \(S1/\s-2\(srn\s+2 (`power') scaling; this gives a louder mix
2899 but one that might occasionally clip.
2901 center;
2902 c8 c8 c.
2903 *       *       *
2907 One use of the
2908 .B remix
2909 effect is to split an audio file into a set of files, each containing
2910 one of the constituent channels (in order to perform subsequent
2911 processing on individual audio channels).  Where more than a few
2912 channels are involved, a script such as the following (Bourne shell
2913 script) is useful:
2915 #!/bin/sh
2916 chans=\`soxi \-c "$1"\`
2917 while [ $chans \-ge 1 ]; do
2918    chans0=\`printf %02i $chans\`   # 2 digits hence up to 99 chans
2919    out=\`echo "$1"|sed "s/\\(.*\\)\\.\\(.*\\)/\\1-$chans0.\\2/"\`
2920    sox "$1" "$out" remix $chans
2921    chans=\`expr $chans \- 1\`
2922 done
2924 If a file
2925 .I input.wav
2926 containing six audio channels were given, the script would produce six
2927 output files:
2928 .IR input-01.wav ,
2929 \fIinput-02.wav\fR, ...,
2930 .IR input-06.wav .
2932 See also
2933 .B mixer
2935 .B swap
2936 for similar effects.
2938 \fBrepeat \fIcount\fR
2939 Repeat the entire audio \fIcount\fR times.
2940 Requires temporary file space to store the audio to be repeated.
2941 Note that repeating once yields two copies: the original audio and the
2942 repeated audio.
2944 \fBreverb\fR [\fB\-w\fR|\fB\-\-wet-only\fR] [\fIreverberance\fR (50%) [\fIHF-damping\fR (50%)
2945 [\fIroom-scale\fR (100%) [\fIstereo-depth\fR (100%)
2947 [\fIpre-delay\fR (0ms) [\fIwet-gain\fR (0dB)]]]]]]
2949 Add reverberation to the audio using the `freeverb' algorithm.  A
2950 reverberation effect is sometimes desirable for concert halls that are too
2951 small or contain so many people that the hall's natural reverberance is
2952 diminished.  Applying a small amount of stereo reverb to a (dry) mono signal
2953 will usually make it sound more natural.  See [3] for a detailed description
2954 of reverberation.
2956 Note that this effect
2957 increases both the volume and the length of the audio, so to prevent clipping
2958 in these domains, a typical invocation might be:
2960    play dry.wav gain \-3 pad 0 3 reverb
2963 .B \-w
2964 option can be given to select only the `wet' signal, thus allowing it to be
2965 processed further, independently of the `dry' signal.  E.g.
2967    play \-m voice.wav "|sox voice.wav \-p reverse reverb \-w reverse"
2969 for a reverse reverb effect.
2971 \fBreverse\fR
2972 Reverse the audio completely.
2973 Requires temporary file space to store the audio to be reversed.
2975 \fBriaa\fR
2976 Apply RIAA vinyl playback equalisation.
2977 The sampling rate must be one of: 44\*d1, 48, 88\*d2, 96 kHz.
2979 This effect supports the \fB\-\-plot\fR global option.
2981 \fBsilence \fR[\fB\-l\fR] \fIabove-periods\fR [\fIduration threshold\fR[\fBd\fR\^|\^\fB%\fR]
2982 [\fIbelow-periods duration threshold\fR[\fBd\fR\^|\^\fB%\fR]]
2984 Removes silence from the beginning, middle, or end of the audio.
2985 `Silence' is determined by a specified threshold.
2987 The \fIabove-periods\fR value is used to indicate if audio should be
2988 trimmed at the beginning of the audio. A value of zero indicates no
2989 silence should be trimmed from the beginning. When specifying an
2990 non-zero \fIabove-periods\fR, it trims audio up until it finds
2991 non-silence. Normally, when trimming silence from beginning of audio
2992 the \fIabove-periods\fR will be 1 but it can be increased to higher
2993 values to trim all audio up to a specific count of non-silence
2994 periods. For example, if you had an audio file with two songs that
2995 each contained 2 seconds of silence before the song, you could specify
2996 an \fIabove-period\fR of 2 to strip out both silence periods and the
2997 first song.
2999 When \fIabove-periods\fR is non-zero, you must also specify a
3000 \fIduration\fR and \fIthreshold\fR. \fIDuration\fR indications the
3001 amount of time that non-silence must be detected before it stops
3002 trimming audio. By increasing the duration, burst of noise can be
3003 treated as silence and trimmed off.
3005 \fIThreshold\fR is used to indicate what sample value you should treat as
3006 silence.  For digital audio, a value of 0 may be fine but for audio
3007 recorded from analog, you may wish to increase the value to account
3008 for background noise.
3010 When optionally trimming silence from the end of the audio, you specify
3011 a \fIbelow-periods\fR count.  In this case, \fIbelow-period\fR means
3012 to remove all audio after silence is detected.
3013 Normally, this will be a value 1 of but it can
3014 be increased to skip over periods of silence that are wanted.  For example,
3015 if you have a song with 2 seconds of silence in the middle and 2 second
3016 at the end, you could set below-period to a value of 2 to skip over the
3017 silence in the middle of the audio.
3019 For \fIbelow-periods\fR, \fIduration\fR specifies a period of silence
3020 that must exist before audio is not copied any more.  By specifying
3021 a higher duration, silence that is wanted can be left in the audio.
3022 For example, if you have a song with an expected 1 second of silence
3023 in the middle and 2 seconds of silence at the end, a duration of 2
3024 seconds could be used to skip over the middle silence.
3026 Unfortunately, you must know the length of the silence at the
3027 end of your audio file to trim off silence reliably.  A work around is
3028 to use the \fBsilence\fR effect in combination with the \fBreverse\fR effect.
3029 By first reversing the audio, you can use the \fIabove-periods\fR
3030 to reliably trim all audio from what looks like the front of the file.
3031 Then reverse the file again to get back to normal.
3033 To remove silence from the middle of a file, specify a
3034 \fIbelow-periods\fR that is negative.  This value is then
3035 treated as a positive value and is also used to indicate the
3036 effect should restart processing as specified by the
3037 \fIabove-periods\fR, making it suitable for removing periods of
3038 silence in the middle of the audio.
3040 The option
3041 .B \-l
3042 indicates that \fIbelow-periods\fR \fIduration\fR length of audio
3043 should be left intact at the beginning of each period of silence.
3044 For example, if you want to remove long pauses between words
3045 but do not want to remove the pauses completely.
3047 The \fIperiod\fR counts are in units of samples. \fIDuration\fR counts
3048 may be in the format of hh:mm:ss.frac, or the exact count of samples.
3049 \fIThreshold\fR numbers may be suffixed with
3050 .B d
3051 to indicate the value is in decibels, or
3052 .B %
3053 to indicate a percentage of maximum value of the sample value
3054 (\fB0%\fR specifies pure digital silence).
3056 The following example shows how this effect can be used to start a recording
3057 that does not contain the delay at the start which usually occurs between
3058 `pressing the record button' and the start of the performance:
3060    rec \fIparameters filename other-effects\fR silence 1 5 2%
3064 \fBsinc\fR [\fB\-a\fI att\fR\^|\^\fB\-b\fI beta\fR] [\fB\-p\fI phase\fR\^|\^\fB\-M\fR\^|\^\fB\-I\fR\^|\^\fB\-L\fR] \:[\fB\-t\fI tbw\fR\^|\^\fB\-n\fI taps\fR] [\fIfreqHP\fR][\fB\-\fIfreqLP\fR [\fB\-t\fR tbw\^|\^\fB\-n\fR taps]]
3066 Apply a sinc kaiser-windowed low-pass, high-pass, band-pass, or band-reject filter
3067 to the signal.
3068 The \fIfreqHP\fR and \fIfreqLP\fR parameters give the frequencies of the
3069 6dB points of a high-pass and low-pass filter that may be invoked
3070 individually, or together.  If both are
3071 given, then \fIfreqHP\fR < \fIfreqLP\fR creates a band-pass filter,
3072 \fIfreqHP\fR > \fIfreqLP\fR creates a band-reject filter.
3074 The default stop-band attenuation of 120dB can be overridden with
3075 \fB\-a\fR; alternatively, the kaiser-window `beta' parameter can be
3076 given directly with \fB\-b\fR.
3078 The default transition band-width of 5% of the total band can be
3079 overridden with \fB\-t\fR (and \fItbw\fR in Hertz); alternatively, the
3080 number of filter taps can be given directly with \fB\-n\fR.
3082 If both \fIfreqHP\fR and \fIfreqLP\fR are given, then a \fB\-t\fR or
3083 \fB\-n\fR option given to the left of the frequencies applies to both
3084 frequencies; one of these options given to the right of the frequencies
3085 applies only to \fIfreqLP\fR.
3088 .BR \-p ,
3089 .BR \-M ,
3090 .BR \-I ,
3092 .B \-L
3093 options control the filter's phase response; see the \fBrate\fR effect
3094 for details.
3096 This effect supports the \fB\-\-plot\fR global option.
3098 \fBspectrogram \fR[\fIoptions\fR]
3099 Create a spectrogram of the audio; the audio is passed unmodified
3100 through the SoX processing chain.  This effect is optional\*mtype
3101 \fBsox \-\-help\fR and check the list of supported effects to see if
3102 it has been included.
3104 The spectrogram is rendered in a Portable Network Graphic (PNG) file,
3105 and shows time in the X-axis, frequency in the Y-axis, and audio
3106 signal magnitude in the Z-axis.  Z-axis values are represented by the
3107 colour (or optionally the intensity) of the pixels in the X-Y plane.
3108 If the audio signal contains multiple channels then these are shown
3109 from top to bottom starting from channel 1 (which is the left channel
3110 for stereo audio).
3112 For example, if `my.wav' is a stereo file, then with
3114    sox my.wav \-n spectrogram
3116 a spectrogram of the entire file will be created in the file
3117 `spectrogram.png'.  More often though, analysis of a smaller portion
3118 of the audio is required; e.g. with
3120    sox my.wav \-n remix 2 trim 20 30 spectrogram
3122 the spectrogram shows information only from the second (right)
3123 channel, and of thirty seconds of audio starting from twenty seconds
3124 in.  To analyse a small portion of the frequency domain, the
3125 .B rate
3126 effect may be used, e.g.
3128    sox my.wav \-n rate 6k spectrogram
3130 allows detailed analysis of frequencies up to 3kHz (half the sampling
3131 rate) i.e. where the human auditory system is most sensitive.
3132 With
3134    sox my.wav \-n trim 0 10 spectrogram \-x 600 \-y 200 \-z 100
3136 the given options control the size of the spectrogram's X, Y & Z axes
3137 (in this case, the spectrogram area of the produced image will be 600
3138 by 200 pixels in size and the Z-axis range will be 100 dB).  Note that
3139 the produced image includes axes legends etc. and so will be a little
3140 larger than the specified spectrogram size.  In this example:
3142    sox \-n \-n synth 6 tri 10k:14k spectrogram \-z 100 \-w kaiser
3144 an analysis `window' with high dynamic range is selected to best
3145 display the spectrogram of a swept triangular wave.  For a smilar
3146 example, append the following to the `chime' command in the
3147 description of the
3148 .B delay
3149 effect (above):
3151    rate 2k spectrogram \-X 200 \-Z \-10 \-w kaiser
3153 Options are also avaliable to control the appearance (colour-set,
3154 brightness, contrast, etc.) and filename of the spectrogram; e.g. with
3156    sox my.wav \-n spectrogram \-m \-l \-o print.png
3158 a spectrogram is created suitable for printing on a `black and white'
3159 printer.
3161 .I Options:
3163 .IP \fB\-x\ \fInum\fR
3164 Change the (maximum) width (X-axis) of the spectrogram from its default
3165 value of 800 pixels to a given number between 100 and 5000.
3166 See also \fB\-X\fR and \fB\-d\fR.
3167 .IP \fB\-X\ \fInum\fR
3168 X-axis pixels/second; the default is auto-calculated to fit the given
3169 or known audio duration to the X-axis size, or 100 otherwise.  If
3170 given in conjunction with \fB\-d\fR, this option affects the width of
3171 the spectrogram; otherwise, it affects the duration of the
3172 spectrogram.
3173 .I num
3174 can be from 1 (low time resolution) to 5000 (high time resolution)
3175 and need not be an integer.  SoX
3176 may make a slight adjustment to the given number for processing
3177 quantisation reasons; if so, SoX will report the actual number used
3178 (viewable when the SoX global option
3179 .B \-V
3180 is in effect).
3181 See also \fB\-x\fR and \fB\-d\fR.
3182 .IP \fB\-y\ \fInum\fR
3183 Sets the Y-axis size in pixels (per channel); this is the number of
3184 frequency `bins' used in the Fourier analysis that produces the
3185 spectrogram.  N.B. it can be slow to produce the spectrogram if this
3186 number is not one more than a power of two (e.g. 129).  By default the
3187 Y-axis size is chosen automatically (depending on the number of
3188 channels).  See
3189 .B \-Y
3190 for alternative way of setting spectrogram height.
3191 .IP \fB\-Y\ \fInum\fR
3192 Sets the target total height of the spectrogram(s).  The default value
3193 is 550 pixels.  Using this option (and by default), SoX will choose a
3194 height for individual spectrogram channels that is one more than a
3195 power of two, so the actual total height may fall short of the given
3196 number.  However, there is also a minimum height per channel so if
3197 there are many channels, the number may be exceeded.
3199 .B \-y
3200 for alternative way of setting spectrogram height.
3201 .IP \fB\-z\ \fInum\fR
3202 Z-axis (colour) range in dB, default 120.  This sets the dynamic-range
3203 of the spectrogram to be \-\fInum\fR\ dBFS to 0\ dBFS.
3204 .I Num
3205 may range from 20 to 180.  Decreasing dynamic-range effectively
3206 increases the `contrast' of the spectrogram display, and vice versa.
3207 .IP \fB\-Z\ \fInum\fR
3208 Sets the upper limit of the Z-axis in dBFS.
3209 A negative
3210 .I num
3211 effectively increases the `brightness' of the spectrogram display,
3212 and vice versa.
3213 .IP \fB\-q\ \fInum\fR
3214 Sets the Z-axis quantisation, i.e. the number of different colours (or
3215 intensities) in which to render Z-axis
3216 values.  A small number (e.g. 4) will give a `poster'-like effect making
3217 it easier to discern magnitude bands of similar level.  Small numbers
3218 also usually
3219 result in small PNG files.  The number given specifies the number of
3220 colours to use inside the Z-axis range; two colours are reserved to
3221 represent out-of-range values.
3222 .IP \fB\-w\ \fIname\fR
3223 Window: Hann (default), Hamming, Bartlett, Rectangular or Kaiser.  The
3224 spectrogram is produced using the Discrete Fourier Transform (DFT)
3225 algorithm.  A significant parameter to this algorithm is the choice of
3226 `window function'.  By default, SoX uses the Hann window which has good
3227 all-round frequency-resolution and dynamic-range properties.  For better
3228 frequency resolution (but lower dynamic-range), select a Hamming window;
3229 for higher dynamic-range (but poorer frequency-resolution), select a
3230 Kaiser window.  Bartlett and Rectangular windows are also available.
3231 .IP \fB\-W\ \fInum\fR
3232 Window adjustment parameter.  This can be used to make small
3233 adjustments to the Kaiser window shape.  A positive number (up to
3234 ten) increases its dynamic range, a negative number decreases it.
3235 .IP \fB\-s\fR
3236 Allow slack overlapping of DFT windows.
3237 This can, in some cases, increase image sharpness and give greater adherence
3238 to the
3239 .B \-x
3240 value, but at the expense of a little spectral loss.
3241 .IP \fB\-m\fR
3242 Creates a monochrome spectrogram (the default is colour).
3243 .IP \fB\-h\fR
3244 Selects a high-colour palette\*mless visually pleasing than the default
3245 colour palette, but it may make it easier to differentiate different levels.
3246 If this option is used in conjunction with
3247 .BR \-m ,
3248 the result will be a hybrid monochrome/colour palette.
3249 .IP \fB\-p\ \fInum\fR
3250 Permute the colours in a colour or hybrid palette.
3252 .I num
3253 parameter, from 1 (the default) to 6, selects the permutation.
3254 .IP \fB\-l\fR
3255 Creates a `printer friendly' spectrogram with a light background (the
3256 default has a dark background).
3257 .IP \fB\-a\fR
3258 Suppress the display of the axis lines.  This is sometimes useful in
3259 helping to discern artefacts at the spectrogram edges.
3260 .IP \fB\-r\fR
3261 Raw spectrogram: suppress the display of axes and legends.
3262 .IP \fB\-A\fR
3263 Selects an alternative, fixed colour-set.  This is provided only for
3264 compatibility with spectrograms produced by another package.  It should
3265 not normally be used as it has some problems, not least, a lack of
3266 differentiation at the bottom end which results in masking of low-level
3267 artefacts.
3268 .IP \fB\-t\ \fItext\fR
3269 Set the image title\*mtext to display above the spectrogram.
3270 .IP \fB\-c\ \fItext\fR
3271 Set (or clear) the image comment\*mtext to display below and to the
3272 left of the spectrogram.
3273 .IP \fB\-o\ \fItext\fR
3274 Name of the spectrogram output PNG file, default `spectrogram.png'.
3278 .I Advanced Options:
3280 In order to process a smaller section of audio without affecting other
3281 effects or the output signal (unlike when the
3282 .B trim
3283 effect is used), the following options may be used.
3285 .IP \fB\-d\ \fIduration\fR
3286 This option sets the X-axis resolution such that audio with the given
3287 .I duration
3288 ([[HH:]MM:]SS) fits the selected (or default) X-axis width.  For
3289 example,
3291    sox input.mp3 output.wav \-n spectrogram \-d 1:00 stats
3293 creates a spectrogram showing the first minute of the audio, whilst
3296 .B stats
3297 effect is applied to the entire audio signal.
3299 See also
3300 .B \-X
3301 for an alternative way of setting the X-axis resolution.
3302 .IP \fB\-S\ \fItime\fR
3303 Start the spectrogram at the given point in the audio stream.  For
3304 example
3306    sox input.aiff output.wav spectrogram \-S 1:00
3308 creates a spectrogram showing all but the first minute of the audio
3309 (the output file however, receives the entire audio stream).
3313 For the ability to perform off-line processing of spectral data, see the
3314 .B stat
3315 effect.
3317 \fBspeed \fIfactor\fR[\fBc\fR]
3318 Adjust the audio speed (pitch and tempo together).  \fIfactor\fR
3319 is either the ratio of the new speed to the old speed: greater
3320 than 1 speeds up, less than 1 slows down, or, if appended with the
3321 letter
3322 `c', the number of cents (i.e. 100ths of a semitone) by
3323 which the pitch (and tempo) should be adjusted: greater than 0
3324 increases, less than 0 decreases.
3326 By default, the speed change is performed by resampling with the \fBrate\fR
3327 effect using its default quality/speed.  For higher quality or higher speed
3328 resampling, in addition to the \fBspeed\fR effect, specify
3329 the \fBrate\fR effect with the desired quality option.
3331 See also the
3332 .B pitch
3334 .B tempo
3335 effects.
3337 \fBsplice \fR [\fB\-h\fR\^|\^\fB\-t\fR\^|\^\fB\-q\fR] { \fIposition\fR[\fB,\fIexcess\fR[\fB,\fIleeway\fR]] }
3338 Splice together audio sections.  This effect provides two things over
3339 simple audio concatenation: a (usually short) cross-fade is applied at
3340 the join, and a wave similarity comparison is made to help determine the
3341 best place at which to make the join.
3343 One of the options
3344 .BR \-h ,
3345 .BR \-t ,
3347 .B \-q
3348 may be given to select the fade envelope as triangular (a.k.a. linear)
3349 (the default), half-cosine wave, or quarter-cosine wave respectively.
3351 center;
3352 cI lI lI lI
3353 cB l l l.
3354 Type    Audio   Fade level      Transitions
3355 t       correlated      constant gain   abrupt
3356 h       correlated      constant gain   smooth
3357 q       uncorrelated    constant power  smooth
3361 To perform a splice, first use the
3362 .B trim
3363 effect to select the audio sections to be joined together.  As when
3364 performing a tape splice, the end of the section to be spliced onto
3365 should be trimmed with a small
3366 .I excess
3367 (default 0\*d005 seconds) of audio after the ideal joining point.  The
3368 beginning of the audio section to splice on should be trimmed with the
3369 same
3370 .IR excess
3371 (before the ideal joining point), plus an additional
3372 .I leeway
3373 (default 0\*d005 seconds).  SoX should then be invoked with the two
3374 audio sections as input files and the
3375 .B splice
3376 effect given with the position at which to perform the splice\*mthis is
3377 length of the first audio section (including the excess).
3379 For example, a long song begins with two verses which start (as
3380 determined e.g. by using the
3381 .B play
3382 command with the
3383 .B trim
3384 (\fIstart\fR) effect) at times 0:30\*d125 and 1:03\*d432.
3385 The following commands cut out the first verse:
3387    sox too-long.wav part1.wav trim 0 30.130
3389 (5 ms excess, after the first verse starts)
3391    sox too-long.wav part2.wav trim 1:03.422
3393 (5 ms excess plus 5 ms leeway, before the second verse starts)
3395    sox part1.wav part2.wav just-right.wav splice 30.130
3397 For another example, the SoX command
3399    play "|sox \-n \-p synth 1 sin %1" "|sox \-n \-p synth 1 sin %3"
3401 generates and plays two notes, but there is a nasty click at the
3402 transition; the click can be removed by splicing instead of
3403 concatenating the audio, i.e. by appending \fBsplice 1\fR to the
3404 command. (Clicks at the beginning and end of the audio can be removed by
3405 \fIpreceding\fR the splice effect with \fBfade q .01 2 .01\fR).
3407 Provided your arithmetic is good enough, multiple splices can be
3408 performed with a single
3409 .B splice
3410 invocation.  For example:
3412 #!/bin/sh
3413 # Audio Copy and Paste Over
3414 # acpo infile copy-start copy-stop paste-over-start outfile
3415 # All times measured in samples.
3416 rate=\`soxi \-r "$1"\`
3417 e=\`expr $rate '*' 5 / 1000\`  # Using default excess
3418 l=$e                         # and leeway.
3419 sox "$1" piece.wav trim \`expr $2 \- $e \- $l\`s \\
3420    \`expr $3 \- $2 + $e + $l + $e\`s
3421 sox "$1" part1.wav trim 0 \`expr $4 + $e\`s
3422 sox "$1" part2.wav trim \`expr $4 + $3 \- $2 \- $e \- $l\`s
3423 sox part1.wav piece.wav part2.wav "$5" splice \\
3424    \`expr $4 + $e\`s \\
3425    \`expr $4 + $e + $3 \- $2 + $e + $l + $e\`s
3427 In the above Bourne shell script,
3428 two splices are used to `copy and paste' audio.
3430 center;
3431 c8 c8 c.
3432 *       *       *
3436 It is also possible to use this effect to perform general cross-fades,
3437 e.g. to join two songs.  In this case,
3438 .I excess
3439 would typically be an number of seconds, the
3440 .B \-q
3441 option would typically be given (to select an `equal power' cross-fade), and
3442 .I leeway
3443 should be zero (which is the default if
3444 .B \-q
3445 is given).  For example, if f1.wav and f2.wav are audio files
3446 to be cross-faded, then
3448    sox f1.wav f2.wav out.wav splice \-q $(soxi \-D f1.wav),3
3450 cross-fades the files where the point of equal loudness is 3 seconds
3451 before the end of f1.wav, i.e. the total length of the cross-fade is
3452 2 \(mu 3 = 6 seconds (Note: the $(...) notation is POSIX shell).
3454 \fBstat\fR [\fB\-s \fIscale\fR] [\fB\-rms\fR] [\fB\-freq\fR] [\fB\-v\fR] [\fB\-d\fR]
3455 Display time and frequency domain statistical information about the audio.
3456 Audio is passed unmodified through the SoX processing chain.
3458 The information is output to the `standard error' (stderr) stream and is
3459 calculated, where
3460 .I n
3461 is the duration of the audio in samples,
3462 .I c
3463 is the number of audio channels,
3464 .I r
3465 is the audio sample rate, and
3466 .I x\s-2\dk\u\s0
3467 represents the PCM value (in the range \-1 to +1 by default) of each successive
3468 sample in the audio,
3469 as follows:
3471 center;
3472 lI l l.
3473 Samples read    \fIn\fR\^\(mu\^\fIc\fR  \ 
3474 Length (seconds)        \fIn\fR\^\(di\^\fIr\fR
3475 Scaled by       \       See \-s below.
3476 Maximum amplitude       max(\fIx\s-2\dk\u\s0\fR)        T{
3477 The maximum sample value in the audio; usually this will be a positive number.
3479 Minimum amplitude       min(\fIx\s-2\dk\u\s0\fR)        T{
3480 The minimum sample value in the audio; usually this will be a negative number.
3482 Midline amplitude       \(12\^min(\fIx\s-2\dk\u\s0\fR)\^+\^\(12\^max(\fIx\s-2\dk\u\s0\fR)
3483 Mean norm       \(S1/\s-2n\s+2\^\(*S\^\^\(br\^\fIx\s-2\dk\u\s0\fR\^\(br\^       T{
3484 The average of the absolute value of each sample in the audio.
3486 Mean amplitude  \(S1/\s-2n\s+2\^\(*S\^\fIx\s-2\dk\u\s0\fR       T{
3487 The average of each sample in the audio.  If this figure is non-zero, then it indicates the
3488 presence of a D.C. offset (which could be removed using the
3489 .B dcshift
3490 effect).
3492 RMS amplitude   \(sr(\(S1/\s-2n\s+2\^\(*S\^\fIx\s-2\dk\u\s0\fR\(S2)     T{
3493 The level of a D.C. signal that would have the same power
3494 as the audio's average power.
3496 Maximum delta   max(\^\(br\^\fIx\s-2\dk\u\s0\fR\^\-\^\fIx\s-2\dk\-1\u\s0\fR\^\(br\^)
3497 Minimum delta   min(\^\(br\^\fIx\s-2\dk\u\s0\fR\^\-\^\fIx\s-2\dk\-1\u\s0\fR\^\(br\^)
3498 Mean delta      \(S1/\s-2n\-1\s+2\^\(*S\^\^\(br\^\fIx\s-2\dk\u\s0\fR\^\-\^\fIx\s-2\dk\-1\u\s0\fR\^\(br\^
3499 RMS delta       \(sr(\(S1/\s-2n\-1\s+2\^\(*S\^(\fIx\s-2\dk\u\s0\fR\^\-\^\fIx\s-2\dk\-1\u\s0\fR)\(S2)
3500 Rough frequency \       In Hz.
3501 Volume Adjustment       \       T{
3502 The parameter to the
3503 .B vol
3504 effect which would make the audio as loud as possible without clipping.
3505 Note: See the discussion on
3506 .B Clipping
3507 above for reasons why it is rarely a good idea actually to do this.
3512 Note that the delta measurements are not applicable for multi-channel audio.
3515 .B \-s
3516 option can be used to scale the input data by a given factor.
3517 The default value of
3518 .I scale
3519 is 2147483647 (i.e. the maximum value of a 32-bit signed integer).
3520 Internal effects
3521 always work with signed long PCM data and so the value should relate to this
3522 fact.
3525 .B \-rms
3526 option will convert all output average values to `root mean square'
3527 format.
3530 .B \-v
3531 option displays only the `Volume Adjustment' value.
3534 .B \-freq
3535 option calculates the input's power spectrum (4096 point DFT) instead of the
3536 statistics listed above.  This should only be used with a single channel
3537 audio file.
3540 .B \-d
3541 option
3542 displays a hex dump of the 32-bit signed PCM data
3543 audio in SoX's internal buffer.
3544 This is mainly used to help track down endian problems that
3545 sometimes occur in cross-platform versions of SoX.
3547 See also the
3548 .B stats
3549 effect.
3551 \fBstats\fR [\fB\-b \fIbits\fR\^|\^\fB\-x \fIbits\fR\^|\^\fB\-s \fIscale\fR] [\fB\-w \fIwindow-time\fR]
3552 Display time domain statistical information about the audio channels;
3553 audio is passed unmodified through the SoX processing chain.
3554 Statistics are calculated and displayed for each audio channel and,
3555 where applicable, an overall figure is also given.
3557 For example, for a typical well-mastered stereo music file:
3559 center;
3561 .ft CW
3562              Overall     Left      Right
3563 DC offset   0.000803 \-0.000391  0.000803
3564 Min level  \-0.750977 \-0.750977 \-0.653412
3565 Max level   0.708801  0.708801  0.653534
3566 Pk lev dB      \-2.49     \-2.49     \-3.69
3567 RMS lev dB    \-19.41    \-19.13    \-19.71
3568 RMS Pk dB     \-13.82    \-13.82    \-14.38
3569 RMS Tr dB     \-85.25    \-85.25    \-82.66
3570 Crest factor       \-      6.79      6.32
3571 Flat factor     0.00      0.00      0.00
3572 Pk count           2         2         2
3573 Bit-depth      16/16     16/16     16/16
3574 Num samples    7.72M
3575 Length s     174.973
3576 Scale max   1.000000
3577 Window s       0.050
3578 .ft R
3582 .IR DC\ offset ,
3583 .IR Min\ level ,
3585 .I Max\ level
3586 are shown, by default, in the range \(+-1.
3587 If the
3588 .B \-b
3589 (bits) options is given, then these three measurements will be scaled to a signed integer
3590 with the given number of bits; for example, for 16 bits, the scale would be \-32768 to +32767.
3592 .B \-x
3593 option behaves the same way as
3594 .B \-b
3595 except that the signed integer values are displayed in hexadecimal.
3597 .B \-s
3598 option scales the three measurements by a given floating-point number.
3600 .I Pk\ lev\ dB
3602 .I RMS\ lev\ dB
3603 are standard peak and RMS level measured in dBFS.
3604 .I RMS\ Pk\ dB
3606 .I RMS\ Tr\ dB
3607 are peak and trough values for RMS level measured over a short window (default 50ms).
3609 .I Crest\ factor
3610 is the standard ratio of peak to RMS level (note: not in dB).
3612 .I Flat\ factor
3613 is a measure of the flatness (i.e. consecutive samples with the same value) of the signal at
3614 its peak levels (i.e. either
3615 .IR Min\ level ,
3617 .IR Max\ level ).
3618 .I Pk\ count
3619 is the number of occasions (not the number of samples) that the signal attained either
3620 .IR Min\ level ,
3622 .IR Max\ level .
3624 The right-hand
3625 .I Bit-depth
3626 figure is the standard definition of bit-depth i.e. bits less
3627 significant than the given number are fixed at zero.  The left-hand
3628 figure is the number of most significant bits that are fixed at zero (or
3629 one for negative numbers) subtracted from the right-hand figure (the
3630 number subtracted is directly related to
3631 .IR Pk\ lev\ dB ).
3633 For multi-channel audio, an overall figure for each of the above
3634 measurements is given and derived from the channel figures as follows:
3635 .IR DC\ offset :
3636 maximum magnitude;
3637 .IR Max\ level ,
3638 .IR Pk\ lev\ dB ,
3639 .IR RMS\ Pk\ dB ,
3640 .IR Bit-depth :
3641 maximum;
3642 .IR Min\ level ,
3643 .IR RMS\ Tr\ dB :
3644 minimum;
3645 .IR RMS\ lev\ dB ,
3646 .IR Flat\ factor ,
3647 .IR Pk\ count :
3648 average;
3649 .IR Crest\ factor :
3650 not applicable.
3652 .I Length\ s
3653 is the duration in seconds of the audio, and
3654 .I Num\ samples
3655 is equal to the sample-rate multiplied by
3656 .IR Length .
3657 .I Scale\ Max
3658 is the scaling applied to the first three measurements;
3659 specifically, it is the maximum value that could apply to
3660 .IR Max\ level .
3661 .I Window\ s
3662 is the length of the window used for the peak and trough RMS measurements.
3664 See also the
3665 .B stat
3666 effect.
3668 \fBswap\fR
3669 Swap stereo channels.
3670 See also
3671 .B remix
3672 for an effect that allows arbitrary channel selection and ordering
3673 (and mixing).
3675 \fBstretch \fIfactor\fR [\fIwindow fade shift fading\fR]
3676 Change the audio duration (but not its pitch).
3677 This effect is broadly equivalent to the
3678 .B tempo
3679 effect with (\fIfactor\fR inverted and)
3680 .I search
3681 set to zero, so in general, its results are comparatively poor;
3682 it is retained as it can sometimes out-perform
3683 .B tempo
3684 for small
3685 .IR factor s.
3687 .I factor
3688 of stretching: >1 lengthen, <1 shorten duration.
3689 .I window
3690 size is in ms.  Default is 20ms.  The
3691 .I fade
3692 option, can be `lin'.
3693 .I shift
3694 ratio, in [0 1].  Default depends on stretch factor. 1
3695 to shorten, 0\*d8 to lengthen.  The
3696 .I fading
3697 ratio, in [0 0\*d5].  The amount of a fade's default depends on
3698 .I factor
3699 and \fIshift\fR.
3701 See also the
3702 .B tempo
3703 effect.
3706 \fBsynth\fR [\fB\-j \fIKEY\fR] [\fB\-n\fR] [\fIlen\fR [\fIoff\fR [\fIph\fR [\fIp1\fR [\fIp2\fR [\fIp3\fR]]]]]] {[\fItype\fR] [\fIcombine\fR] \:[[\fB%\fR]\fIfreq\fR[\fBk\fR][\fB:\fR\^|\^\fB+\fR\^|\^\fB/\fR\^|\^\fB\-\fR[\fB%\fR]\fIfreq2\fR[\fBk\fR]]] [\fIoff\fR [\fIph\fR [\fIp1\fR [\fIp2\fR [\fIp3\fR]]]]]}
3708 This effect can be used to generate fixed or swept frequency audio tones
3709 with various wave shapes, or to generate wide-band noise of various
3710 `colours'.
3711 Multiple synth effects can be cascaded to produce more complex
3712 waveforms; at each stage it is possible to choose whether the generated
3713 waveform will be mixed with, or modulated onto
3714 the output from the previous stage.
3715 Audio for each channel in a multi-channel audio file can be synthesised
3716 independently.
3718 Though this effect is used to generate audio, an input file must still
3719 be given, the characteristics of which will be used to set the
3720 synthesised audio length, the number of channels, and the sampling rate;
3721 however, since the input file's audio is not normally needed, a `null
3722 file' (with the special name \fB\-n\fR) is often given instead (and the
3723 length specified as a parameter to \fBsynth\fR or by another given
3724 effect that can has an associated length).
3726 For example, the following produces a 3 second, 48kHz,
3727 audio file containing a sine-wave swept from 300 to 3300\ Hz:
3729    sox \-n output.wav synth 3 sine 300-3300
3731 and this produces an 8\ kHz version:
3733    sox \-r 8000 \-n output.wav synth 3 sine 300-3300
3735 Multiple channels can be synthesised by specifying the set of
3736 parameters shown between braces multiple times;
3737 the following puts the swept tone in the left channel and adds `brown'
3738 noise in the right:
3740    sox \-n output.wav synth 3 sine 300-3300 brownnoise
3742 The following example shows how two synth effects can be cascaded
3743 to create a more complex waveform:
3745 .ne 2
3746    play \-n synth 0.5 sine 200-500 synth 0.5 sine fmod 700-100
3748 Frequencies can also be given in `scientific' note notation, or, by
3749 prefixing a `%' character, as a number of semitones relative to
3750 `middle A' (440\ Hz).  For example, the following could be used to
3751 help tune a guitar's low `E' string:
3753    play \-n synth 4 pluck %-29
3755 or with a (Bourne shell) loop, the whole guitar:
3757 .ne 2
3758    for n in E2 A2 D3 G3 B3 E4; do
3759         play \-n synth 4 pluck $n repeat 2; done
3761 See the
3762 .B delay
3763 effect (above) and the reference to `SoX scripting examples' (below)
3764 for more
3765 .B synth
3766 examples.
3768 .B N.B.
3769 This effect generates audio at maximum volume (0dBFS), which means that there
3770 is a high chance of clipping when using the audio subsequently, so
3771 in many cases, you will want to follow this effect with the \fBgain\fR
3772 effect to prevent this from happening. (See also
3773 .B Clipping
3774 above.)
3775 Note that, by default, the
3776 .B synth
3777 effect incorporates the functionality of \fBgain \-h\fR (see the
3778 .B gain
3779 effect for details);
3780 .BR synth 's
3781 .B \-n
3782 option may be given to disable this behaviour.
3784 A detailed description of each
3785 .B synth
3786 parameter follows:
3788 \fIlen\fR is the length of audio to synthesise expressed as a time
3789 or as a number of samples;
3790 0=inputlength, default=0.
3792 The format for specifying lengths in time is hh:mm:ss.frac.  The format
3793 for specifying sample counts is the number of samples with the letter
3794 `s' appended to it.
3796 \fItype\fR is one of sine, square, triangle, sawtooth, trapezium, exp,
3797 [white]noise, tpdfnoise pinknoise, brownnoise, pluck; default=sine.
3799 \fIcombine\fR is one of create, mix, amod (amplitude modulation), fmod
3800 (frequency modulation); default=create.
3802 \fIfreq\fR/\fIfreq2\fR are the frequencies at the beginning/end of
3803 synthesis in Hz or, if preceded with `%', semitones relative to A
3804 (440\ Hz); alternatively, `scientific' note notation (e.g. E2) may
3805 be used.  The default frequency is 440Hz.  By default, the tuning used
3806 with the note notations is `equal temperament'; the
3807 .B \-j
3808 .I KEY
3809 option selects `just intonation', where
3810 .I KEY
3811 is an integer number of semitones relative to A (so for example, \-9
3812 or 3 selects the key of C), or a note in scientific notation.
3815 .I freq2
3816 is given, then
3817 .I len
3818 must also have been given and the generated tone will be swept between
3819 the given frequencies.  The two given frequencies must be separated by
3820 one of the characters `:', `+', `/', or `\-'.  This character is used to
3821 specify the sweep function as follows:
3823 .IP \fB:\fR
3824 Linear: the tone will change by a fixed number of hertz per second.
3825 .IP \fB+\fR
3826 Square: a second-order function is used to change the tone.
3827 .IP \fB/\fR
3828 Exponential: the tone will change by a fixed number of semitones per second.
3829 .IP \fB\-\fR
3830 Exponential: as `/', but initial phase always zero, and stepped (less
3831 smooth) frequency changes.
3835 Not used for noise.
3837 \fIoff\fR is the bias (DC-offset) of the signal in percent; default=0.
3839 \fIph\fR is the phase shift in percentage of 1 cycle; default=0.  Not
3840 used for noise.
3842 \fIp1\fR is the percentage of each cycle that is `on' (square), or
3843 `rising' (triangle, exp, trapezium); default=50 (square, triangle, exp),
3844 default=10 (trapezium), or sustain (pluck); default=40.
3846 \fIp2\fR (trapezium): the percentage through each cycle at which `falling'
3847 begins; default=50. exp: the amplitude in multiples of 2dB; default=50,
3848 or tone-1 (pluck); default=20.
3850 \fIp3\fR (trapezium): the percentage through each cycle at which `falling'
3851 ends; default=60, or tone-2 (pluck); default=90.
3853 \fBtempo \fR[\fB\-q\fR] [\fB\-m\fR\^|\^\fB\-s\fR\^|\^\fB\-l\fR] \fIfactor\fR [\fIsegment\fR [\fIsearch\fR [\fIoverlap\fR]]]
3854 Change the audio playback speed but not its pitch. This effect uses the
3855 WSOLA algorithm. The audio is chopped up into segments which are then
3856 shifted in the time domain and overlapped (cross-faded) at points where
3857 their waveforms are most similar as determined by measurement of `least
3858 squares'.
3860 By default, linear searches are used to find the best overlapping
3861 points. If the optional
3862 .B \-q
3863 parameter is given, tree searches are used instead. This makes the effect
3864 work more quickly, but the result may not sound as good. However, if you
3865 must improve the processing speed, this generally reduces the sound quality
3866 less than reducing the search or overlap values.
3869 .B \-m
3870 option is used to optimize default values of segment, search and
3871 overlap for music processing.
3874 .B \-s
3875 option is used to optimize default values of segment, search and
3876 overlap for speech processing.
3879 .B \-l
3880 option is used to optimize default values of segment, search and
3881 overlap for `linear' processing that tends to cause more
3882 noticeable distortion but may be useful when factor is close to 1.
3884 If \-m, \-s, or \-l is specified, the default value of segment will be
3885 calculated based on factor, while default search and overlap values are
3886 based on segment. Any values you provide still override these default
3887 values.
3889 .I factor
3890 gives the ratio of new tempo to the old tempo, so e.g. 1.1 speeds up the
3891 tempo by 10%, and 0.9 slows it down by 10%.
3893 The optional
3894 .I segment
3895 parameter selects the algorithm's segment size in milliseconds.  If no other
3896 flags are specified, the default value is 82 and is typically suited to
3897 making small changes to the tempo of music. For larger changes (e.g. a factor
3898 of 2), 41\ ms may give a better result.  The \-m, \-s, and \-l flags will cause
3899 the segment default to be automatically adjusted based on factor.
3900 For example using \-s (for speech) with a tempo of 1.25 will calculate a
3901 default segment value of 32.
3903 The optional
3904 .I search
3905 parameter gives the audio length in milliseconds over which
3906 the algorithm will search for overlapping points.  If no other
3907 flags are specified, the default value is 14.68.  Larger values use
3908 more processing time and may or may not produce better results.
3909 A practical maximum is half the value of segment. Search
3910 can be reduced to cut processing time at the risk of degrading output
3911 quality. The \-m, \-s, and \-l flags will cause
3912 the search default to be automatically adjusted based on segment.
3914 The optional
3915 .I overlap
3916 parameter gives the segment overlap length in milliseconds.
3917 Default value is 12, but \-m, \-s, or \-l flags automatically
3918 adjust overlap based on segment size. Increasing overlap increases
3919 processing time and may increase quality. A practical maximum for overlap
3920 is the value of search, with overlap typically being (at least) a little
3921 smaller then search.
3923 See also
3924 .B speed
3925 for an effect that changes tempo and pitch together,
3926 .B pitch
3927 for an effect that changes tempo and pitch together, and
3928 .B stretch
3929 for an effect that changes tempo using a different algorithm.
3931 \fBtreble \fIgain\fR [\fIfrequency\fR[\fBk\fR]\fR [\fIwidth\fR[\fBs\fR\^|\^\fBh\fR\^|\^\fBk\fR\^|\^\fBo\fR\^|\^\fBq\fR]]]
3932 Apply a treble tone-control effect.
3933 See the description of the \fBbass\fR effect for details.
3935 \fBtremolo \fIspeed\fR [\fIdepth\fR]
3936 Apply a tremolo (low frequency amplitude modulation) effect to the audio.
3937 The tremolo frequency in Hz is given by
3938 .IR speed ,
3939 and the depth as a percentage by
3940 .I depth
3941 (default 40).
3943 \fBtrim \fIstart\fR [\fIlength\fR\^|\^\fB=\fIend\fR]
3944 Trim can trim off unwanted audio from the beginning and end of the
3945 audio.  Audio is not sent to the output stream until
3946 the \fIstart\fR location is reached.
3948 The optional \fIlength\fR parameter gives the length of audio to output
3949 after the \fIstart\fR sample and is thus used to trim off the end of the
3950 audio.  Alternatively, an absolute end location can be given by
3951 preceding it with an equals sign.  Using a value of 0 for the \fIstart\fR
3952 parameter will allow trimming off the end only.
3954 Both parameters can be specified using either an amount of time or an
3955 exact count of samples.  The format for specifying lengths in time is
3956 hh:mm:ss.frac.  A start value of 1:30\*d5 will not start until 1 minute,
3957 thirty and \(12 seconds into the audio.  The format for specifying
3958 sample counts is the number of samples with the letter `s' appended to
3959 it.  A value of 8000s for the \fIstart\fR parameter will wait until
3960 8000 samples are read before starting to process audio.
3962 \fBvad \fR[\fIoptions\fR]
3963 Voice Activity Detector.  Attempts to trim silence and quiet
3964 background sounds from the ends of (fairly high resolution
3965 i.e. 16-bit, 44-48kHz) recordings of speech.  The algorithm currently
3966 uses a simple cepstral power measurement to detect voice, so may be
3967 fooled by other things, especially music.  The effect can trim only
3968 from the front of the audio, so in order to trim from the back, the
3969 .B reverse
3970 effect must also be used.  E.g.
3972    play speech.wav norm vad
3974 to trim from the front,
3976    play speech.wav norm reverse vad reverse
3978 to trim from the back, and
3980    play speech.wav norm vad reverse vad reverse
3982 to trim from both ends.  The use of the
3983 .B norm
3984 effect is recommended, but remember that neither
3985 .B reverse
3987 .B norm
3988 is suitable for use with streamed audio.
3990 .I Options:
3992 Default values are shown in parenthesis.
3994 .IP \fB\-t\ \fInum\fR\ (7)
3995 The measurement level used to trigger activity detection.  This might
3996 need to be changed depending on the noise level, signal level and
3997 other charactistics of the input audio.
3998 .IP \fB\-T\ \fInum\fR\ (0.25)
3999 The time constant (in seconds) used to help ignore short bursts of
4000 sound.
4001 .IP \fB\-s\ \fInum\fR\ (1)
4002 The amount of audio (in seconds) to search for quieter/shorter bursts
4003 of audio to include prior to the detected trigger point.
4004 .IP \fB\-g\ \fInum\fR\ (0.25)
4005 Allowed gap (in seconds) between quieter/shorter bursts of audio to
4006 include prior to the detected trigger point.
4007 .IP \fB\-p\ \fInum\fR\ (0)
4008 The amount of audio (in seconds) to preserve before the trigger point
4009 and any found quieter/shorter bursts.
4013 .I Advanced Options:
4015 These allow fine tuning of the alogithm's internal parameters.
4017 .IP \fB\-b\ \fInum\fR
4018 The algorithm (internally) uses adaptive noise estimation/reduction in
4019 order to detect the start of the wanted audio.  This option sets the
4020 time for the initial noise estimate.
4021 .IP \fB\-N\ \fInum\fR
4022 Time constant used by the adaptive noise estimator for when the noise
4023 level is increasing.
4024 .IP \fB\-n\ \fInum\fR
4025 Time constant used by the adaptive noise estimator for when the noise
4026 level is decreasing.
4027 .IP \fB\-r\ \fInum\fR
4028 Amount of noise reduction to use in the detection algorithm (e.g. 0,
4029 0.5, ...).
4030 .IP \fB\-f\ \fInum\fR
4031 Frequency of the algorithm's processing/measurements.
4032 .IP \fB\-m\ \fInum\fR
4033 Measurement duration; by default, twice the measurement period; i.e.
4034 with overlap.
4035 .IP \fB\-M\ \fInum\fR
4036 Time constant used to smooth spectral measurements.
4037 .IP \fB\-h\ \fInum\fR
4038 `Brick-wall' frequency of high-pass filter applied at the input to the
4039 detector algorithm.
4040 .IP \fB\-l\ \fInum\fR
4041 `Brick-wall' frequency of low-pass filter applied at the input to the
4042 detector algorithm.
4043 .IP \fB\-H\ \fInum\fR
4044 `Brick-wall' quefrency of high-pass lifter used in the detector
4045 algorithm.
4046 .IP \fB\-L\ \fInum\fR
4047 `Brick-wall' quefrency of low-pass lifter used in the detector
4048 algorithm.
4052 See also the
4053 .B silence
4054 effect.
4056 \fBvol \fIgain\fR [\fItype\fR [\fIlimitergain\fR]]
4057 Apply an amplification or an attenuation to the audio signal.
4058 Unlike the
4059 .B \-v
4060 option (which is used for balancing multiple input files as they enter the
4061 SoX effects processing chain),
4062 .B vol
4063 is an effect like any other so can be applied anywhere, and several times
4064 if necessary, during the processing chain.
4066 The amount to change the volume is given by
4067 .I gain
4068 which is interpreted, according to the given \fItype\fR, as follows: if
4069 .I type
4070 is \fBamplitude\fR (or is omitted), then
4071 .I gain
4072 is an amplitude (i.e. voltage or linear) ratio,
4073 if \fBpower\fR, then a power (i.e. wattage or voltage-squared) ratio,
4074 and if \fBdB\fR, then a power change in dB.
4076 When
4077 .I type
4078 is \fBamplitude\fR or \fBpower\fR, a
4079 .I gain
4080 of 1 leaves the volume unchanged,
4081 less than 1 decreases it,
4082 and greater than 1 increases it;
4083 a negative
4084 .I gain
4085 inverts the audio signal in addition to adjusting its volume.
4087 When
4088 .I type
4089 is \fBdB\fR, a
4090 .I gain
4091 of 0 leaves the volume unchanged,
4092 less than 0 decreases it,
4093 and greater than 0 increases it.
4095 See [4]
4096 for a detailed discussion on electrical (and hence audio signal)
4097 voltage and power ratios.
4099 Beware of
4100 .B Clipping
4101 when the increasing the volume.
4104 .I gain
4105 and the
4106 .I type
4107 parameters can be concatenated if desired, e.g.
4108 .BR "vol 10dB" .
4110 An optional \fIlimitergain\fR value can be specified and should be a
4111 value much less
4112 than 1 (e.g. 0\*d05 or 0\*d02) and is used only on peaks to prevent clipping.
4113 Not specifying this parameter will cause no limiter to be used.  In verbose
4114 mode, this effect will display the percentage of the audio that needed to be
4115 limited.
4117 See also
4118 .B gain
4119 for a volume-changing effect with different capabilities, and
4120 .B compand
4121 for a dynamic-range compression/expansion/limiting effect.
4122 .SS Deprecated Effects
4123 The following effects have been renamed or have their functionality
4124 included in another effect; they continue to work in this version of
4125 SoX but may be removed in future.
4127 \fBfilter\fR [\fIlow\fR]\fB\-\fR[\fIhigh\fR] [\fIwindow-len\fR [\fIbeta\fR]]
4128 Apply a sinc-windowed lowpass, highpass, or bandpass filter of given
4129 window length to the signal.
4130 This effect has been superseded by the \fBsinc\fR effect.
4131 Compared with `sinc', `filter' is slower and has fewer capabilities.
4133 \fIlow\fR refers to the frequency of the lower 6dB corner of the filter.
4134 \fIhigh\fR refers to the frequency of the upper 6dB corner of the filter.
4136 A low-pass filter is obtained by leaving \fIlow\fR unspecified, or 0.
4137 A high-pass filter is obtained by leaving \fIhigh\fR unspecified, or 0,
4138 or greater than or equal to the Nyquist frequency.
4140 The \fIwindow-len\fR, if unspecified, defaults to 128.
4141 Longer windows give a sharper cut-off, smaller windows a more gradual cut-off.
4143 The \fIbeta\fR parameter
4144 determines the type of filter window used.  Any value greater than 2 is
4145 the beta for a Kaiser window.  Beta \(<= 2 selects a Blackman-Nuttall window.
4146 If unspecified, the default is a Kaiser window with beta 16.
4148 In the case of Kaiser window (beta > 2), lower betas produce a
4149 somewhat faster transition from pass-band to stop-band, at the cost of
4150 noticeable artifacts. A beta of 16 is the default, beta less than 10
4151 is not recommended. If you want a sharper cut-off, don't use low
4152 beta's, use a longer sample window. A Blackman-Nuttall window is selected by
4153 specifying any `beta' \(<= 2, and the Blackman-Nuttall window has somewhat
4154 steeper cut-off than the default Kaiser window. You will probably not
4155 need to use the beta parameter at all, unless you are just curious
4156 about comparing the effects of Blackman-Nuttall vs. Kaiser windows.
4158 This effect supports the \fB\-\-plot\fR global option.
4160 \fBkey \fR[\fB\-q\fR] \fIshift\fR [\fIsegment\fR [\fIsearch\fR [\fIoverlap\fR]]]
4161 Change the audio key (i.e. pitch but not tempo).
4162 This is just an alias for the
4163 .B pitch
4164 effect.
4166 \fBpan \fIdirection\fR
4167 Mix the audio from one channel to another.
4169 .B mixer
4171 .B remix
4172 instead of this effect.
4175 .I direction
4176 is a value from \-1 to 1.  \-1 represents
4177 far left and 1 represents far right.
4179 \fBpolyphase\fR [\fB\-w nut\fR\^|\^\fBham\fR] [\fB\-width \fIn\fR] [\fB\-cut-off \fIc\fR]
4181 \fBrabbit\fR [\fB\-c0\fR\^|\^\fB\-c1\fR\^|\^\fB\-c2\fR\^|\^\fB\-c3\fR\^|\^\fB\-c4\fR]
4183 \fBresample\fR [\fB\-qs\fR\^|\^\fB\-q\fR\^|\^\fB\-ql\fR] [\fIrolloff\fR [\fIbeta\fR]]
4184 .if t .sp -.5
4185 .if n .sp -1
4188 Formerly sample-rate-changing effects in their own right, these are now just aliases for the
4189 .B rate
4190 effect.
4191 .SH DIAGNOSTICS
4192 Exit status is 0 for no error, 1 if there is a problem with the
4193 command-line parameters, or 2 if an error occurs during file processing.
4194 .SH BUGS
4195 Please report any bugs found in this version of SoX to the mailing list
4196 (sox-users@lists.sourceforge.net).
4197 .SH SEE ALSO
4198 .BR soxi (1),
4199 .BR soxformat (7),
4200 .BR libsox (3)
4202 .BR audacity (1),
4203 .BR gnuplot (1),
4204 .BR octave (1),
4205 .BR wget (1)
4207 The SoX web site at http://sox.sourceforge.net
4209 SoX scripting examples at http://sox.sourceforge.net/Docs/Scripts
4210 .SS References
4213 R. Bristow-Johnson,
4214 .IR "Cookbook formulae for audio EQ biquad filter coefficients" ,
4215 http://musicdsp.org/files/Audio-EQ-Cookbook.txt
4218 Wikipedia,
4219 .IR "Q-factor" ,
4220 http://en.wikipedia.org/wiki/Q_factor
4223 Scott Lehman,
4224 .IR "Effects Explained" ,
4225 http://harmony-central.com/Effects/effects-explained.html
4228 Wikipedia,
4229 .IR "Decibel" ,
4230 http://en.wikipedia.org/wiki/Decibel
4233 Richard Furse,
4234 .IR "Linux Audio Developer's Simple Plugin API" ,
4235 http://www.ladspa.org
4238 Richard Furse,
4239 .IR "Computer Music Toolkit" ,
4240 http://www.ladspa.org/cmt
4243 Steve Harris,
4244 .IR "LADSPA plugins" ,
4245 http://plugin.org.uk
4246 .SH LICENSE
4247 Copyright 1998\-2011 Chris Bagwell and SoX Contributors.
4249 Copyright 1991 Lance Norskog and Sundry Contributors.
4251 This program is free software; you can redistribute it and/or modify
4252 it under the terms of the GNU General Public License as published by
4253 the Free Software Foundation; either version 2, or (at your option)
4254 any later version.
4256 This program is distributed in the hope that it will be useful,
4257 but WITHOUT ANY WARRANTY; without even the implied warranty of
4258 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4259 GNU General Public License for more details.
4260 .SH AUTHORS
4261 Chris Bagwell (cbagwell@users.sourceforge.net).
4262 Other authors and contributors are listed in the ChangeLog file that
4263 is distributed with the source code.