How to install SoX on CentOS 6

To install SoX on CentOS 6

SoX (Sound eXchange) is a cross-platform sound file format converter. SoX can convert between many different digitized sound formats and perform simple sound manipulation functions, including sound effects. It can combine multiple input sources and synthesise audio and act as general purpose audio player or a multi-track audio recorder. This tutorial covers the installation procedure of SoX on CentOS 6.

Installation procedure

To start with the installation procedure of SoX, download the required repository using wget command followed by the download link.

[root@linuxhelp ~]# wget http://repository.it4i.cz/mirrors/repoforge/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
--2017-10-28 15:06:19--  http://repository.it4i.cz/mirrors/repoforge/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
Resolving repository.it4i.cz... 195.113.250.52, 2001:718:1007:48::1:52
Connecting to repository.it4i.cz|195.113.250.52|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12640 (12K) [application/x-rpm]
Saving to: “ rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm” 

100%[====================================================================================================================================================================> ] 12,640      --.-K/s   in 0s      

2017-10-28 15:06:21 (689 MB/s) - “ rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm”  saved [12640/12640]

The package has been downloaded and now install the package by running the following command.

[root@linuxhelp ~]# rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
warning: rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
Preparing...                ########################################### [100%]
   1:rpmforge-release       ########################################### [100%]

Next install the required dependencies for the SoX to run in the environment. Execute the yum install command followed by the dependencies.

[root@linuxhelp ~]# yum install gcc-c++ libmad libmad-devel libid3tag libid3tag-devel lame lame-devel flac-devel libvorbis-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Determining fastest mirrors
 * base: mirrors.vonline.vn
 * extras: mirrors.nhanhoa.com
 * rpmforge: repoforge.mirror.wearetriple.com
 * updates: mirrors.nhanhoa.com
base                                                                                                                                                                                   | 3.7 kB     00:00     
extras                                                                                                                                                                                 | 3.4 kB     00:00     
extras/primary_db                                                                                                                                                                      |  29 kB     00:00     
rpmforge                                                                                                                                                                               | 1.9 kB     00:00     
http://repoforge.mirror.wearetriple.com/redhat/el6/en/x86_64/rpmforge/repodata/primary.sqlite.bz2: [Errno 12] Timeout on http://repoforge.mirror.wearetriple.com/redhat/el6/en/x86_64/rpmforge/repodata/primary.sqlite.bz2: (28, ' Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds' )
rpmforge/primary_db                                                                                                                                                                    | 2.7 MB     00:00     
updates                                                                                                                                                                                | 3.4 kB     00:00     
updates/primary_db                                                                                                                                                                     | 4.7 MB     00:00     
Resolving Dependencies
-->  Running transaction check
--->  Package flac-devel.x86_64 0:1.2.1-7.el6_6 will be installed
--->  Package gcc-c++.x86_64 0:4.4.7-18.el6 will be installed
-->  Processing Dependency: libstdc++-devel = 4.4.7-18.el6 for package: gcc-c++-4.4.7-18.el6.x86_64
-->  Processing Dependency: gcc = 4.4.7-18.el6 for package: gcc-c++-4.4.7-18.el6.x86_64
.
.
.
.
Verifying  : gcc-4.4.7-18.el6.x86_64                                                                                                                                                                 14/18 
  Verifying  : gcc-c++-4.4.7-18.el6.x86_64                                                                                                                                                             15/18 
  Verifying  : ppl-0.10.2-11.el6.x86_64                                                                                                                                                                16/18 
  Verifying  : cloog-ppl-0.15.7-1.2.el6.x86_64                                                                                                                                                         17/18 
  Verifying  : automake-1.11.1-4.el6.noarch                                                                                                                                                            18/18 

Installed:
  flac-devel.x86_64 0:1.2.1-7.el6_6          gcc-c++.x86_64 0:4.4.7-18.el6       lame.x86_64 0:3.99.5-1.el6.rf             lame-devel.x86_64 0:3.99.5-1.el6.rf         libid3tag.x86_64 0:0.15.1b-11.el6   
  libid3tag-devel.x86_64 0:0.15.1b-11.el6    libmad.x86_64 0:0.15.1b-4.el6.rf    libmad-devel.x86_64 0:0.15.1b-4.el6.rf    libvorbis-devel.x86_64 1:1.2.3-4.el6_2.1   

Dependency Installed:
  autoconf.noarch 0:2.63-5.1.el6          automake.noarch 0:1.11.1-4.el6   cloog-ppl.x86_64 0:0.15.7-1.2.el6   cpp.x86_64 0:4.4.7-18.el6   gcc.x86_64 0:4.4.7-18.el6   libogg-devel.x86_64 2:1.1.4-2.1.el6  
  libstdc++-devel.x86_64 0:4.4.7-18.el6   mpfr.x86_64 0:2.4.1-6.el6        ppl.x86_64 0:0.10.2-11.el6         

Complete!

Download the latest stable SoX package using wget command followed by the download link.

[root@linuxhelp ~]# wget https://nchc.dl.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.gz
--2017-10-28 15:12:31--  https://nchc.dl.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.gz
Resolving nchc.dl.sourceforge.net... 211.79.60.17, 2001:e10:ffff:1f02::17
Connecting to nchc.dl.sourceforge.net|211.79.60.17|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1134299 (1.1M) [application/x-gzip]
Saving to: “ sox-14.4.2.tar.gz” 

100%[===================================================================================================================================================================> ] 1,134,299    318K/s   in 3.5s    

2017-10-28 15:12:36 (318 KB/s) - “ sox-14.4.2.tar.gz”  saved [1134299/1134299]

Extract the downloaded package by running the tar command.

[root@linuxhelp ~]# tar -xvzf sox-14.4.2.tar.gz
sox-14.4.2/
sox-14.4.2/config.sub
sox-14.4.2/aclocal.m4
sox-14.4.2/COPYING
sox-14.4.2/cygbuild
sox-14.4.2/src/
sox-14.4.2/src/gsrt.c
sox-14.4.2/src/tx16w.c
sox-14.4.2/src/tremolo.c
sox-14.4.2/src/vox-fmt.c
sox-14.4.2/src/compandt.c
.
.
.
.
sox-14.4.2/lpc10/dyptrk.c
sox-14.4.2/lpc10/lpcini.c
sox-14.4.2/lpc10/lpfilt.c
sox-14.4.2/lpc10/difmag.c
sox-14.4.2/lpc10/voicin.c
sox-14.4.2/lpc10/ham84.c
sox-14.4.2/lpc10/placea.c
sox-14.4.2/lpc10/CMakeLists.txt
sox-14.4.2/LICENSE.GPL
sox-14.4.2/CMakeLists.txt
sox-14.4.2/sox.txt

Move to the SoX directory and run the following script to configure the SoX in the target system.

[root@linuxhelp ~]# cd sox-14.4.2
[root@linuxhelp sox-14.4.2]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
.
.
.
.
config.status: creating msvc9/Makefile
config.status: creating msvc10/Makefile
config.status: creating sox.pc
config.status: creating src/soxconfig.h
config.status: executing depfiles commands
config.status: executing libtool commands

After running ./configure you should see in output:
OPTIONAL FILE FORMATS
amrnb......................no
amrwb......................no
flac.......................yes
gsm........................yes (in-tree)
lpc10......................yes (in-tree)
mp2/mp3....................yes
 id3tag....................no
 lame......................yes
 lame id3tag...............yes
 dlopen lame...............no
 mad.......................yes
 dlopen mad................no
 twolame...................no
oggvorbis..................yes
opus.......................no
sndfile....................no
wavpack....................no

OTHER OPTIONS
ladspa effects.............no
magic support..............no
png support................no
OpenMP support.............yes, -fopenmp

The configuration process has been finished and now run the make -s command in the terminal.

[root@linuxhelp sox-14.4.2]# make -s
Making all in lpc10
  CC       analys.lo
  CC       bsynz.lo
  CC       chanwr.lo
  CC       dcbias.lo
  CC       decode.lo
  CC       deemp.lo
  CC       difmag.lo
  CC       dyptrk.lo
  CC       encode.lo
  CC       energy.lo
  CC       f2clib.lo
  CC       ham84.lo
  CC       hp100.lo
  CC       invert.lo
.
.
.
CC       example2.o
  CCLD     example2
  CC       example3.o
  CCLD     example3
  CC       example4.o
  CCLD     example4
  CC       example5.o
  CCLD     example5
  CC       example6.o
  CCLD     example6

Next run the make install command in the terminal.

[root@linuxhelp sox-14.4.2]# make install 
Making install in lpc10
make[1]: Entering directory `/root/sox-14.4.2/lpc10' 
make[2]: Entering directory `/root/sox-14.4.2/lpc10' 
make[2]: Nothing to be done for `install-exec-am' .
make[2]: Nothing to be done for `install-data-am' .
make[2]: Leaving directory `/root/sox-14.4.2/lpc10' 
make[1]: Leaving directory `/root/sox-14.4.2/lpc10' 
Making install in libgsm
.
.
.
.
cd /usr/local/share/man/man1 & &  rm -f play.1 & &  ln -s sox.1 play.1
cd /usr/local/share/man/man1 & &  rm -f rec.1 & &  ln -s sox.1 rec.1
cd /usr/local/share/man/man7 & &  rm -f soxeffect.7 & &  ln -s ../man1/sox.1 soxeffect.7
make[3]: Leaving directory `/root/sox-14.4.2' 
make[2]: Leaving directory `/root/sox-14.4.2' 
make[1]: Leaving directory `/root/sox-14.4.2' 

Enter into the downloaded location to list a sound file for converting into another format.

[root@linuxhelp ~]# cd /root/Desktop/
[root@linuxhelp Desktop]# ll
total 1292
-rwxrw-rw- 1 root root 1322298 Oct 31 16:42 Kurzweil-K2000-Dual-Bass-C1.wav

Convert the sound file to .wav format using SoX applicaton and now list the files in the intended directory. There will be the original sound file along with the converted one.

[root@linuxhelp Desktop]# sox Kurzweil-K2000-Dual-Bass-C1.wav Kurzweil-K2000-Dual-Bass-C1.mp3
[root@linuxhelp Desktop]# ll
total 1412
-rw-r--r-- 1 root root  120372 Oct 31 16:47 Kurzweil-K2000-Dual-Bass-C1.mp3
-rwxrw-rw- 1 root root 1322298 Oct 31 16:42 Kurzweil-K2000-Dual-Bass-C1.wav

Now view the properties of the converted file format and you can see the file format has been changed from .wav to .mp3 file format.

The original file format as .wav file along with file location is viewed in the properties window.

The file is running successfully in the system.

Thus we conclude the installation procedure of SoX on CentOS 6.

Comment
johndennisgt
Apr 28 2021
Worked perfectly well
prayingmantis
Jul 04 2020
Thank u so much, u saved me :o \o/
Add a comment
FAQ
Q
What are the best 'rate' settings to resample a file and retain the highest quality?
A
Resampling is a series of compromises so there's no one true answer for all situations, but the following rules of thumb should cover most people's needs for 99% of the time:

Phase setting: if resampling to < 40k, use intermediate phase (-I), otherwise use linear phase (-L, or don't specify; linear phase is the default).
Quality setting: if resampling (or changing speed, as it amounts to the same thing) at/to > 16-bit depth (i.e. most commonly 24-bit), use VHQ (-v), otherwise, use HQ (-h, or don't specify).
Bandwidth setting: don't change from the default setting (95%).
If you're mastering to 16-bit, you also need to add 'dither' (and in most cases noise-shaping) after the rate.

Time for some examples:

sox any-file -b 16 outfile rate 44100 dither -s

(mastering for CDDA).

sox 24-bit-file outfile rate -v 88200

(outfile bit depth unchanged at 24-bit).

sox any-file -b 16 outfile rate -I 22050 dither -s

N.B. Both resampling and dithering require some headroom. If SoX reports that any clipping has occurred during processing then the conversion should be redone with some attenuation, e.g.

sox any-file -b 16 outfile gain -1 rate 44100 dither -s
Q
Why doesn't this SoX command line I found on the internet work?
A
A number of potentially confusing options have been replaced with what we hope are less confusing ones; e.g. -b & -w in SoX versions prior to 14.1.0 are now -b (or --bits) 8, and -b 16, and -e is now -n.

The ChangeLog contains full details of any backwards-compatibility issues.
Q
How to get the official documentation for the Sox?
A
Get the official documentation for the Sox, use the following link as given below, "http://sox.sourceforge.net/Docs/Documentation"
Q
What are the alternative for the SoX?
A
The following tools are available for the SoX as, Adobe Audition, Amadeus Pro, Free Audio Editor, Ecasound
Q
How to get the source of the SoX?
A
For download the source of the SOX, use the followinng link as below "http://sox.sourceforge.net/"