Wednesday, July 06, 2005

Putting MP3s into SoX

I mentioned previously that one of the things I wanted to do with Fedora Core 4 was to find an MP3-enabled version of SoX, "the Swiss Army Knife" of sound processing programs. In FC3 I found a SoX+MP3 RPM file online. I still haven't found one for FC4. Fortunately, however, I found a hint for creating such an RPM online (search for "sox").

The procedure is rather simple, if you're willing to rebuild RPM files:

  1. Set up your account so that you can build RPM files.
  2. Find a copy of sox-*.src.rpm, where the "*" is the version number. The current version is 12.17.7-3, so you'll look for sox-12.17.7-3.src.rpm. This is available in any mirror of Fedora Core 4, I found it in
    ftp://ftp.linux.ncsu.edu/pub/fedora/linux/core/4/SRPMS/
  3. Copy sox-12.17.7-3.src.rpm to ~/rpmbuild/SRPMS.
  4. Make sure the packages lame, lame-devel, libmad, and libmad-devel are installed. If not, you'll need to install them. Assuming you followed Fedora Core Tips & Tricks to enable the freshrpms repository, you can do:
    sudo yum install libmad libmad-devel lame lame-devel
    where sudo allows selected users to run root commands. If you these packages are already installed, yum will let you know about it.
  5. Now create the RPM. From a terminal window:
    $ cd ~/rpmbuild/SRPMS
    $ sudo rpmbuild --rebuild sox*

    and wait awhile.
  6. When the program is finished,
    $ cd ~/rpmbuild/RPMS/i386
    $ ls sox*

    There should be three files with RPM extensions: sox*, sox-devel*, and sox-debuginfo*, where "*" hides all the version numbers and stuff. Since these RPMs were compiled with the lame and mad libraries, they contain an MP3 enabled version of SoX.
  7. Now for the tricky part: we have to get the non-MP3 version of SoX off the system and replace it with the MP3-enabled version. This is difficult because a) the version of SoX on your system is probably the same as the one you just complied, so the rpm database won't recognize your version as an upgrade; and b) some programs depend on SoX to run, so the dependency checker in rpm will generate an error. To get rid of the old SoX, then, we must force the uninstall:
    $ rpm -e --nodeps sox sox-devel
    assuming that you had sox-devel on your system.
  8. Now we can install the brand-new version of SoX:
    $ sudo rpm -i sox-12.17.7-3.i386.rpm sox-devel-12.17.7-3.i386.rpm
  9. Now test the program. Run
    $ sox -h
    At the bottom of the output is a list of supported file formats. If you see "mp3", then SoX works.
  10. Use SoX as before.

Note that if freshrpms ever updates SoX, you'll lose the MP3 capability and will have to repeat all of this stuff again. :-(

1 comments:

Anonymous said...

Hey, thanks for the instructions. They worked great.