Recording Sounds

As with many types of programs, Linux sound recording programs can be classified into one of two categories: text-based and GUI. The most common text-based sound recording program is rec, which is installed as part of the sox package. (In fact, rec is a symbolic link to play; the program records or plays sounds depending upon the name you use to call it.) Here is the basic syntax for rec:

rec [options] filename [effects]

The filename is, of course, the filename to be used. The options affect the basic file format—the sample rate, number of channels, and so on. The effects modify the recorded sound—they create echoes, fades, and so on. Table 8.1 summarizes some of the more important options. Consult the sox man page for information on effects.

Table 8.1 : Important Options forree




-cnum or-channels=/7um

The number of channels recorded

Typically 1 or 2

-f format or -format=format

Bit format of the recording

s (signed linear), u (unsigned linear), U (U-law logarithmic), a (ADPCM), A (A-law logarithmic), or g (GSM)

-r rate or-rate=rate

Number of samples per second

Typically 8000 through 48000

-s size or-size=s/ze

Size of each sample

b (8-bit), w (16-bit), I (32-bit), f (32-bit floating-point), d (64-bit floating-point), or D (80-bit floating-point)

-t type or-type=type

Audio file format

Common audio filename extensions, such as wav or au

-x or-xinu

Reverses the byte order when size isw or I. Necessary when transferring some files across platforms


If some of the options in Table 8.1 seem unfamiliar, don't be overly concerned. You can use the defaults, or use common values: signed linear (s) or unsigned linear (u) format, sample sizes of 8-bit (b) or 16-bit (w), and wav files. The most important options in determining the quality of reproduction are the sample rate and sample size. For reference, audio CDs use a rate of 44,100 with a 16-bit sample size. For stereo recordings, of course, you must specify two channels. For instance, you can create a recording (and then play it back) with commands such as the following:

$ rec -t wav -r 44100 -s w -c 2 sample.wav $ play sample.wav

These commands have some caveats associated with them:

• You must have the appropriate audio inputs to your sound card. This includes mixer levels, which must be set to record from your chosen input source. Chapter 1 provides more information on mixers.

• The rec program doesn't know when to stop recording; therefore, you must press Ctrl+C when you've finished.

0 0

Post a comment