FIRST STEPS

In this chapter we'll take some first steps towards the basic use of AGNULA. You'll learn how to play, record, and store sound using some of AGNULA's simpler tools, and you will also learn that, in true UNIX fashion, the simplest tools often conceal great capabilities and real power.

We'll begin by considering our baseline audio system connections.

TOGETHERNESS

The following flowcharts illustrate how you should set up a basic system for recording and playing back sound under GNU/Linux. To record, take this route :

    soundcard input (mic, CD, line) ---> mixer (set alsamixer capture channel) ---> recording software (arecord)
For playback, it works in reverse order :

    playback software (aplay) ---> mixer (set alsamixer playback channel) ---> soundcard output
If your hardware and software is all in place, we can test this system and start our exploration of AGNULA by performing the following tasks :

  1. Record a CD-quality soundfile
  2. Play it back
  3. Apply an effect to it
  4. Convert the soundfile + effects to OGG and CDDA formats
  5. Burn it to an audio CD
RECORDING WITH ARECORD

Before you can record anything you must activate a 'capture' (ALSA-speak for 'record') channel on your system mixer. Raise the input channel level slider to about 3/4 of its scale. Beware of feedback: start by testing your levels with modest settings for the master and input channels, and place your microphone facing away from your speakers. Now open an xterm window and invoke ALSA's arecord with the following command options :

    arecord -d 10 -f cd -t wav /your/soundfile/directory/foo.wav
Before hitting the Enter key, note that these options will set arecord to capture the signal coming in on the input channel for 10 seconds ('-d 10') and save the recording as a CD-quality file ('-f cd' records the input to a stereo soundfile with 16-bit resolution and a sampling rate of 44.1 kHz) in the WAV format ('-t wav'). Arecord has many other options, you can see them all by typing 'man arecord' in an open console or xterm window.

PLAYBACK WITH APLAY

Now that we have a file named foo.wav in your particular soundfile directory (I have mine in /home/dlphilp/soundfiles) let's play it back using the ALSA aplay utility :

    aplay /your/soundfile/directory/foo.wav
Aplay can learn about the format details from the file's header, but like arecord aplay has many useful options. See them all at 'man aplay'.

ADDING EFFECTS WITH SOX

Next we want to add some reverberation and delay to our new file, so we'll use the SoX utility in this way :

    sox foo.wav fooverb.wav reverb 1 2500 125
Here the options indicate a reverb effect to be added to the foo.wav input file with a gain amount of 1, a reverb time of 2500 milliseconds, and a delay time of 125 milliseconds (higher numbers will space the delays further apart). The input file with its added reverb is then saved as fooverb.wav.

ENCODING TO OGG FORMAT

Our next task is really two tasks, and both involve file format conversion. AGNULA's compressed file format of choice is the OGG format, and all of the Ogg/Vorbis tools have been included with the distribution. Just run the following command to create your first OGG file :

    oggenc fooverb.wav
The OGG encoder (oggenc) will encode with its default values and create a fooverb.ogg file as its output. Oggenc will also issue this report to your console or xterm :

    [[email protected] dlphilp]$ oggenc fooverb.wav 
    Opening with wav module: WAV file reader
    Encoding "fooverb.ogg" [ 99.6%] [ 0m00s remaining]

    Done encoding file "fooverb.ogg"

            File length:  0m 34.0s
            Elapsed time: 0m 06.9s
            Rate:         4.9542
            Average bitrate: 251.0 kb/s
In Chapter XX we'll learn how to set up and broadcast from a streaming OGG server and how to listen to OGG audio streams from other servers, but for now let's move on to the next step, converting our new fooverb.wav to a format suitable for burning to an audio CD.

BURNING TO COMPACT DISC

We'll invoke one more utility from the AGNULA toolchest. Cdrecord is included with almost all mainstream Linux distributions, and of course you have it here in AGNULA. Once you've created and modified several WAV-format soundfiles you can invoke cdrecord to burn your masterworks to disc. Here's how it's done :

    cdrecord dev=/dev/scd0 -audio foo-01.wav foo-02.wav foo-03.wav foo-04.wav ...
The 'dev' value is required (here it's the first SCSI device), but if you don't know what device to specify you can run cdrecord with only its '-scanbus' option to determine the device value of your CD burner. The '-audio' flag tells cdrecord that it's burning audio files to disc. Fortunately, cdrecord performs automatic conversion from WAV or AU to CDDA as long as the original files are CD-quality recordings (and you can always use SoX to convert almost any audio file format to CDDA). And of course cdrecord has a great number of other options that you can read about via 'man cdrecord'.

Before leaving these exercises I want to again point out that excellent and very handy manual (man) pages exist for all these utilities. Console users should be especially pleased by this availability in a non-X environment, but they are equally valuable while working in the Linux GUI. The man pages for the programs presented in this chapter are truly useful and well-written, so remember: man is your friend.

THE WRAP

So that's it, we've accomplished our tasks, from simple recording and playback to burning a file (plus effects!) to a CD. Now take a moment and consider that if we can do all this with only these humble command-line tools, what lies in store for us with the more complex and powerful applications included with AGNULA ? We'll just have to proceed to find out...

ADDITIONAL EXERCISES