A Basic Text-Based Recording Studio

Shrinkwrapped audio gear too expensive? Too inflexible? Perhaps not geeky enough? Why not use a Linux box as the main workhorse in your studio?
Testing Audio Signal and Setting Levels

Before leaping in too far and beginning to record audio, I strongly recommend spending some time getting the various settings and levels right. The good news is that this involves plugging the instrument of your choice in to the mixer or sitting it in front of a microphone and playing.

Begin by getting the average signal coming into the mixer at around the 0VU mark, and try to avoid sending the signal into the red too often. Once the mixer levels are generally okay, connect it to your PC and check that the input level and output level are fine:

ecasound -i jack_auto -o null -ev

The -i jack_auto command-line option tells Ecasound to get its input from JACK. Because we're not running any other JACK-aware applications at the moment, JACK takes this input from the sound device. The -o null tells Ecasound to send output to the great bit bucket in the sky.

The -ev option tells Ecasound to keep track of amplitude statistics, and the -c option starts Ecasound in interactive mode. With a little luck, you should see a few informational messages and no errors or warnings.

Any percussive sounds (such as palm-muting on the guitar) are likely to cause a spike in your audio track. While checking the signal levels, use any of these techniques you intend to record later—it'll save a nasty surprise in the moment of creative genius. To stop, press Ctrl-C. You should be presented with output similar to the following:

(audiofx) Peak amplitude, period: pos=0.30495 neg=0.26996.
(audiofx) Peak amplitude, all : pos=0.30495 neg=0.26996.
(audiofx) Clipped samples, period: pos=0 neg=0.
(audiofx) Clipped samples, all : pos=0 neg=0.
(audiofx) Max gain without clipping, all: 3.27926.
(audiofx) -- End of statistics --------------------------------

First, check that you have no clipped samples (positive or negative). Second, check the maximum gain figure. This gives the percentage that this sample can be amplified (theoretically) before clipping starts to occur. Depending on your hardware, you may never get within a few percentages before you hear audible distortion, so it pays to leave yourself a little room until you're familiar with your hardware. Listen as you test.

Once you have made mixer adjustments, try the previous few steps again.

Once you're happy with the input levels, set the output level to a comfortable level for you to monitor using your headphones.

Recording a First Track or Live Stereo Performance

Ecasound is a command-line tool capable of multitrack recording and more. The basic concept key to using Ecasound is chains. For our purposes, you can consider chains to be similar in function to a patch lead in a patch bay. A signal enters one end of the chain from a sound source and exits the chain into another component. A patch lead has exactly one input source and one output destination, and the same can be said about Ecasound's chain concept.

Sources and destinations for chains in Ecasound are usually audio files or audio controllers. It is quite normal to have a complex set of chains. The first track we will record will see Ecasound take audio from the running JACK instance and write the data back to JACK, as well as keep a copy in a PCM audio file. The two chains we need to perform these tasks are shown in Table 1.

Table 1. Chains for Our First Track

ChainInput SourceOutput Destination

This equates to the following Ecasound command:

ecasound -c -b:64 \
-a:1,2 -i jack_auto \
-a:1 -o jack_auto \
-a:2 -o track1.wav

Once Ecasound has initialised, it prompts you for instructions. Use the t command to start recording/playing and s to stop. If you make a mistake, you can issue a stop (s), the setpos 0 command, and t to start again. The q command quits when you're done. There's no need to issue any kind of command to save the result—that happens as you record.

The above command can be broken down into the following functions:

  • -c: don't start processing immediately, instead enter interactive mode.

  • -b:64: set the number of samples buffered to the smallest possible, reducing latency.

  • -a:1,2 -i jack_auto: create two chains (1 and 2) and set their input to come from JACK.

  • -a:1 -o jack_auto: set the output of chain 1 to JACK.

  • -a:2 -o track1.wav: set the output of chain 2 to track1.wav.

The overall result of this particular example is that chain 2 records anything coming in through JACK (and therefore probably the sound card) to track1.wav. Chain 1 allows you to hear the audio signal as it's being recorded.