# SoX

**URL:** <https://forum.audacityteam.org/t/sox/17179>\
**Category:** Audio Processing\
**Created:** [December 19, 2010, 9:12pm UTC](https://forum.audacityteam.org/t/sox/17179 "2010-12-19T21:12:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [December 19, 2010, 9:12pm UTC](https://forum.audacityteam.org/t/sox/17179/1 "2010-12-19T21:12:17Z")

</div>

SoX ( **So** und e **X** change) is a cross-platform command line program for doing things with audio.  
It can be used to convert between different audio formats, trim, join and mix files, add effects, play and record files, change sample rates and bit depths and many other common audio tasks. It is sometimes likened to a command line sibling to Audacity.

One of the great strengths of SoX is that as a command line utility it can easily be used with batch processing scripts.

Today I have been looking at the “Compander” effect because I had need of an aggressive, fast compressor/limiter effect.

A brief summary of the available commands is given by:

```plaintext
sox -h

```

A brief summary of the effects commands is given by

```plaintext
sox --help-effect <effect>

```

so for the Compander the brief help can be shown with:

```plaintext
sox --help-effect compand

```

This gives:

```plaintext
sox: SoX v14.3.1

Effect usage:

compand attack1,decay1{,attack2,decay2} [soft-knee-dB:]in-dB1[,out-dB1]{,in-dB2,out-dB2} [gain [initial-volume-dB [delay]]]
	where {} means optional and repeatable and [] means optional.
	dB values are floating point or -inf'; times are in seconds.

```

I found this to be a bit more than slightly cryptic, so I looked in the SoX manual [http://sox.sourceforge.net/sox.html#index](http://sox.sourceforge.net/sox.html#index)  
  
  
… more to follow

---

<div class="post-metadata">

**Author:** ![steve](https://forum.audacityteam.org/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://forum.audacityteam.org/u/steve)\
**Post date:** [December 21, 2010, 12:50am UTC](https://forum.audacityteam.org/t/sox/17179/2 "2010-12-21T00:50:54Z")

</div>

I find the compand gain transfer function confusing, but a bit of experimentation produced the heavy compression that I was after.

```plaintext
sox infile.wav outfile.wav compand 0,0.1 -80.1,-inf,-80,-160,-48,-24,-24,-6,-12,-1.5,-6,-0.3 -1 -6 gain -n -0.1

```

The attack is 0 (as fast as possible) and the decay (release) is 0.1 seconds

The next parameter is the gain transfer function.  
The examples in the manual show an odd number of values which is rather confusing IMHO, but taken in pairs is a bit easier to follow:  
-80.1,-inf, (below -80.1 dB the sound is gated)  
-80,-160, (from 80 dB the ratio is 1:2 compression \>\> 2:1 expansion)  
-48,-24, (from -48 dB the ratio is 2:1 compression)  
-24,-6, (from -24 dB the ratio is 4:1 compression)  
-12,-1.5, (from -12 dB the ratio is 8:1 compression)  
-6,-0.3 (from -6 dB the ratio is 20:1 compression)

Overall the effect produces an increasing amount of compression as the input level rises.

The next parameter (-1) provides 1 dB of headroom.  
The final parameter (-6) sets an assumed initial level of -6 dB.

Following the compander effect is the “gain” effect.  
The parameters (-n -0.1) tells the gain effect to normalise to -0.1 dB
