Wednesday, 29 April 2009

  • HowTo: SoX Installation

    HowTo: Compiling SoX with read/write MP3 support in Ubuntu

    SoX describes itself as the "Swiss Army knife of sound processing programs," a well-deserved title given the amount of functionality outlined in the sox(1) man page - one can say it's the command-line version of Audacity.

    Due to patent issues and the typical legal mess, SoX binaries are distributed without MP3 support to avoid licensing fees  (I would prefer an unencumered open format such as Ogg Vorbis, but MP3 remains too common to ignore).  SoX can be given MP3 support, however, be recompiling it to use a third-party library such as LAME.

    Instructions here are specific to Ubuntu (8.10+) but may be adapted for Debian or any other distro that uses APT.
    1. Install packages required for the build environment (ensure that 'multiverse' and 'restricted' repositories are enabled in /etc/apt/sources.list).
      Note that, in Ubuntu 7.10 and 8.04, LAME development libraries are provided by liblame-dev instead of libmp3lame-dev.

      sudo apt-get install build-essentials fakeroot libmp3lame-dev
      sudo apt-get build-dep sox


    2. Retrieve and unpack SoX sources into a clean directory.

      mkdir sox
      cd sox
      apt-get source sox
      dpkg-source -x sox_*.dsc
      cd sox-*.*.*


    3. Remove the '--disable-lame' compiler flag; either use sed to automate the task or manually edit sox-*.*.*/debian/rules with a text editor.

      sed -i~ 's/--disable-lame//g' debian/rules

    4. Build the package.

      dpkg-buildpackage -b

      You should be able to see
      checking lame/lame.h usability... yes
      checking lame/lame.h presence... yes
      checking for lame/lame.h... yes
      checking for lame_init in -lmp3lame... yes
      <snip>
      LAME MP3 writer................... yes
      echoed in the terminal, although it is recommended you redirect stdout to a log file because the messages will likely escape the scrollback buffer before there is a chance to pause and read.
    5. The build will provide all SoX-related packages, but only certain local ones are needed to replace the repository versions.

      cd ..
      sudo dpkg -i sox_*.deb libsox-fmt-mp3_*.deb

    If all proceeds well, sox -h should give something like
    SUPPORTED FILE FORMATS: 8svx aif aifc aiff aiffc al alsa ao au auto avi avr caf cdda cdr cvs cvsd dat dvms fap ffmpeg flac fssd gsm hcom ima ircam la lpc lpc10 lu m3u m4a mat mat4 mat5 maud mp2 mp3 mp4 mpg nist nul null ogg oss ossdsp paf pls prc pvf raw s1 s2 s3 s4 sb sd2 sds sf sl smp snd sndfile sndt sou sph sw txw u1 u2 u3 u4 ub ul uw vms voc vorbis vox w64 wav wavpcm wmv wve xa xi
    Support for extra formats can be obtained through the libsox-fmt-all package.


    HowTo: Recompiling the latest SoX sources

    I found myself desiring the "norm" effect, but, unfortunately, the feature was introduced in version 14.1.0, while the 8.10 repository is stuck at 14.0.1.  In these cases, it becomes necessary to recompile the latest sources.
    1. Download and unpack the latest stable SoX sources for GNU/Linux (currently 14.2.0).  For expediency, wget is used here, but a regular web browser suffices.

      wget http://superb-west.dl.sourceforge.net/sourceforge/sox/sox-14.2.0.tar.gz
      tar -xvzf sox-14.2.0.tar.gz


    2. Set up the build environment.

      sudo apt-get install build-essentials fakeroot checkinstall libmp3lame-dev
      sudo apt-get build-dep sox


      Note that libmp3lame-dev is necessary for MP3 support through LAME, which is not automatically included among the SoX build dependencies due to MP3 patent/licensing issues.
      For Ubuntu 7.10 and 8.04, LAME development headers and libraries are provided by liblame-dev instead.
    3. Compiling involves the same standard procedure...

      cd sox-14.2.0
      ./configure
      make


    4. Due to some strange linking situation in which shared libraries were not detected correctly, the links need to be repaired after installing or SoX will not run.  (This took me a while to figure out.)

      sudo make install
      # Add /usr/local/lib to end of the include paths
      sed -i~ '$s/$/& \/usr\/local\/lib/' /etc/ld.so.conf
      sudo /sbin/ldconfig


    5. For easier uninstallation, checkinstall can create a deb package so APT can keep track of the installed files.

      sudo checkinstall

      Note that SoX is produced as a single package, rather than as multiple packages by repository conventions.
    Download for x64: sox_14.2.0-1_amd64.deb
  • Give eProps (?)

  • New! You can now edit your comments for 15 minutes after submitting.

Who recommended?