User Tools

Site Tools


ubuntu:sound:sox

Ubuntu - Sound - sox

Audio manipulation.

SoX (Sound eXchange) calls itself “the Swiss Army knife of sound processing programs” and offers, apart from standard audio format and sample rate conversion, a basic set of effects (e.g. pitch shifting, reverb, low pass filtering, flanger, etc).

One issue with SoX is that default installs typically do not support writing mp3 files because of the patent and licensing issues with mp3.

Reading mp3 files works after installing the “libsox-fmt-all” package.

If you're up to it, you can recompile SoX with mp3 encoding support, but there are other options if you really want mp3 encoding.


Install sox

aptitude update
apt-get install sox libsox-fmt-all

Minimal conversion example.

sox input.mp3 output.wav

Convert to mono (two possibilities: by specifying output format or with the 'channels' effect.

sox input.mp3 -c 1 output.wav
sox input.mp3 output.wav channels 1

Change sample rate (again two possibilities)

sox input.mp3 -r 8000 output.wav
sox input.mp3 output.wav rate 8000

Newer versions of SoX also support

sox input.mp3 output.wav rate 8k

Trim a fragment of 30 seconds at an offset of 60 seconds with the 'trim' effect.

sox input.mp3 output.wav trim 60 30

All together now (trimmed fragment in mono, 22.05 Hz sample rate)

sox input.mp3 output.wav trim 60 30 channels 1 rate 22050
ubuntu/sound/sox.txt · Last modified: 2020/07/15 10:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki