Converting Audio Files with SoX

If you have a sound file in one format, but you want it to be in another format, Linux offers some conversion tools. The SoX utility can translate to and from any of the audio formats listed in Table 4-1.

. - r | "p""^ I Type sox h to see the supported audio types, as well as supported options and effects.

TABLE 4-1

Sound Formats Supported by the SoX Utility

File Extension or Pseudonym

Description

File Extension or Pseudonym

Description

.8svx

8SVX Amiga musical instrument description format.

.aiff

Apple IIc/IIgs and SGI AIFF files. May require a separate archiver to work with these files.

.au, .snd

Sun Microsystems AU audio files. This was once a popular format. (The .snd extension is ambiguous because it's also been used on the NeXT format and the headerless Mac/PC format.)

.avr

Audio Visual Research format, used on the Mac.

.cdr

CD-R files used to master compact disks.

.cvs

Continuously variable slope delta modulation, which is used for voice mail and other speech compression.

.dat

Text data files, which contain a text representation of sound data.

.gsm

Lossy speech compression (GSM 06.10), used to shrink audio data in voice mail and similar applications.

.hcom

Macintosh HCOM files.

.maud

Amiga format used to produce sound that is 8-bit linear, 16-bit linear, A-law, and u-law in mono or stereo.

.ogg

Ogg Vorbis compressed audio, which is best used for compressing music and streaming audio.

.ossdsp

Pseudo file, used to open the OSS /dev/dsp file and configure it to use the data type passed to SoX. Used to either play or record.

.prc

Psion record.app format, newer than the WVE format. Note that the .prc extension is also used for programs for Palm handheld devices.

.sf

IRCAM sound files, used by the CSound package and the MixView sample editor.

.sph

Speech audio SPHERE (Speech Header Resources) format from NIST (National Institute of Standards and Technology).

.smp

SampleVision files from Turtle Beach, used to communicate with different MIDI samplers.

continued

TABLE 4-1

| (continued)

File Extension or Pseudonym

Description

File Extension or Pseudonym

Description

.sunau

Pseudo file, used to open a /dev/audio file and set it to use the data type being passed to SoX.

.txw

Yamaha TX-16W from a Yamaha sampling keyboard.

.vms

Used to compress speech audio for voice mail and similar applications.

.voc

Sound Blaster VOC file.

.wav

Microsoft WAV RIFF files. This is the native Microsoft Windows sound format.

.wve

8-bit, a-law, and 8 KHz sound files used with Psion Palmtop computers.

.raw

Raw files (contain no header information, so sample rate, size, and style must be given).

.ub, .sb, .uw, .sw, .ul,.al, .lu, .la, .sl

Raw files with set characteristics. ub is an unsigned byte; sb is a signed byte; uw is an unsigned word; sw is a signed word; and ul is ulaw.

If you are not sure about the format of an audio file, you can add the .auto extension to the filename. This triggers SoX to guess what kind of audio format is contained in the file. The .auto extension can be used only for the input file. If SoX can figure out the content of the input file, it translates the contents to the sound type for the output file you request.

In its most basic form, you can convert one file format (such as a WAV file) to another format (such as an AU file) as follows:

$ sox file1.wav file1.au

To see what SoX is doing, use the -V option. For example: $ sox -V file1.wav filel.voc sox: Reading Wave file: Microsoft PCM format, 2 channel, 44100 samp/sec sox: 176400 byte/sec, 4 block align, 16 bits/samp, 50266944 data bytes sox: Input file: using sample rate 11025

size bytes, style unsigned, 1 channel sox: Input file1.wav: comment "file1.wav"

sox: Output file1.voc: using sample rate 44100

size shorts, encoding signed (2's complement), 2 channels sox: Output file: comment "file1.wav"

You can apply sound effects during the SoX conversion process. The following example shows how to change the sample rate (using the -r option) from 10,000 KHz to 5,000 KHz:

$ sox -r 10000 file1.wav -r 5000 filel.voc

To reduce the noise, you can send the file through a low-pass filter. Here's an example: $ sox filel.voc file2.voc lowp 2200

For more information on SoX and to get the latest download, go to the SoX — Sound eXchange — home page(http://sourceforge.net/projects/sox/).

Continue reading here: Compressing Music Files with oggenc

Was this article helpful?

0 0