oreilly.comSafari Books Online.Conferences.


Developing and Using Snd: Editing Sound Under Linux, Part Two
Pages: 1, 2, 3, 4, 5

Selected areas and regions

A highlighted selection area is made by holding down the left mouse button anywhere within the channel graph display and sweeping the mouse to the left or right. The swept area will be highlighted; release the mouse button to finalize your selection (a Select All/Unselect All function is also available from the channel graph pop-up menu). Right-click anywhere within the highlighted area to pop up a menu of actions to perform on the selection, such as playback, loop play, reverse, and copy-to-new.

Screen shot.
The regions browser

A selected area defines a region. View/Regions will call up the Regions Browser [Figure 2], a dialog window that includes a list of all the selections you've made up to that point, including selections from files that have been closed. At present, the browser is not too useful. You can play individual regions and send them to new edit channels, you can lock regions from deletion or further editing, and you can delete selections from the browser. However, the examp.scm file includes code for two forms of sequential playback of regions. This command in the Listener:

(region-play-sequence '(0 2 1))

will play regions 0, 2, and 1 in an uninterrupted sequence. This command:

(region-play-list (list (list 0.0 0) (list 0.5 1) (list 1.0 2) (list 1.0 0)))

will play region 0 at 0.0 seconds, region 1 at .5 seconds, and regions 2 and 0 together at 1 second after the start. Hopefully the regions browser will eventually incorporate these commands into a set of graphic controls.

Mixes and tracks

Standard sound file mixing operations include functions to paste, insert, and replace data. Paste-mix blends the mix file (which Snd just calls a mix) with the original data, insert-mix splices in the mix at the cursor point (lengthening the original by the length of the mix data), and replace-mix wipes out the original data and replaces it with the new.

Snd provides a few different methods of paste-mixing. Double-clicking on a sound file name in the File/Mix dialog will paste-mix that file into the active channel. Alternately, you can drag a highlighted file name from the entry box of any file dialog in Snd and drop it into any channel graph display. Paste-mix is also available from the channel graph pop-up menu, but in this case the mix source is the currently selected area. Make your selection, position the cursor at the mix point, then click on Mix Selection from the pop-up menu. In all these methods the mix is pasted in at the cursor position, and a waveform graphic will appear at the top of the channel display. You can reposition the mix waveform by clicking and dragging the handle at the left end of the graph [Figure 3].

Insert-mix is present as an insert-file action and as an insert-selection operation. To make things easy, I've added an Insert File item to the menu created by the special.scm file. Click on the menu item, select your file from the dialog box, and the original data will be pushed aside by the inserted mix data. The Edit menu and the channel graph pop-up menu both provide an Insert Selection function that operates the same way using the selected area for the mix data. Note too that middle-clicking will insert the last selected area at the cursor position for very fast insert-mixing.

Mix by replacement is also available from the Edit and channel pop-up menus. Once again the mix point is the cursor location in the active channel, and any highlighted data will be mixed into the channel, replacing any existing data from the cursor forward.

Here's a rather elaborate replace-mix technique for a precise remove/edit/replace operation: Select an area in your sound file and copy it to a new file. Snap a pair of marks to the original selection boundaries, then zero out the selected area (copy-to-new, snap-marks, and zero-out are all found in the selection area pop-up menu). Now switch to the copied selection (named newf-n.snd by default), edit and add effects to taste, click on Edit/Select All, then switch back to the original channel. Position the cursor anywhere before the first marker and type C-j to accurately position the cursor at the mark point. Right-click in the channel graph display and choose "Mix selection" or "Replace with selection" from the pop-up menu to replace the zeroed out area with your edited region. If the mix material is longer than the original selection area the mix method will determine whether the mix blends with existing data or replaces it.

Other mixing functions are available via the Mix Panel (see Figure 3), including a way to organize your mix files into tracks. A track is a specifier for a group of mix files: When mixes are defined into a track, any action on one of the track members occurs upon all other members sharing the same track identifier. If you move one mix file, all other mix files with the same track number will be moved too. The Mix Panel also includes speed and amplitude sliders that again can be used to adjust one or several mix files at once. Note that clicking on any mix file in the channel graph will update the mix panel to represent the selected mix.

Mixing creates temporary files stored in Snd's $TMPDIR directory. These files add up, so make sure $TMPDIR points to a spacious directory. I put the following line in my $HOME/.bashrc file to set the temporary files in a large empty directory:

export TMPDIR=/usr/local/dump

Finally, be aware that by default the various mix procedures do not automatically normalize or scale amplitudes. You may want to adjust the gain of your original file, or you can use the Mix Panel amplitude slider to scale the volume of the mix file (or files).

If Cool Edit can do it ...

Now that we know how to designate edit areas, let's perform some of those operations commonly employed by Cool Edit users to see how Snd does the same things.

Amplitude and dynamics processing

Gain and normalization are simple processes. Go to the Effects menu, select the appropriate process, adjust the value slider in the GUI widget, and click on the DoIt button. Most (but not yet all) effects in Snd will call a small hourglass icon to indicate elapsed time during the processing; when the hourglass has filled its bottom half the process is ended and the channel display will update automatically. Gain and normalize can be applied to the whole file, highlighted selection, or marked area.

Cutting and trimming files

The easiest way to cut data from a file is to select it with the mouse, then right-click in the selected area to open the Selection pop-up menu. From there, you can choose to delete or erase the area or to crop the data surrounding the selected area. Alternately, you can cut or copy your selection to a new channel. If you synch a group of files you can perform the same cut over all the synchronized files. Trimming and cropping are also mark operations, available as Scheme code or items in the Marks menu. Trim cuts the file length before or behind a mark; crop cuts everything outside a marked area.

Zooming and high-resolution edits

Snd has excellent zoom controls. You can use the horizontal sliders beneath a sound's channel graph display to adjust zoom factor and and viewing position, or you can use the keyboard's arrow keys to zoom in or out and move the display view from left to right. The zoom focus can be controlled from the whole-file view down to the individual sample level. To the left of the channel graph display, you can see Snd's vertical resolution sliders. These sliders are especially helpful when editing files with very low amplitudes. You can quickly set the x/y axes to minimum or maximum view by middle-clicking at either end of the slider trough.

Some Cool Edit users specifically mentioned that program's use of sinc interpolation between sample points. According to one user, this method of interpolation yields smoother sound, reducing the possibility of clicks after an edit. Snd employs linear interpolation between sample points, but it also provides a smooth-sound function similar to sinc interpolation for smoothing the results of some editing processes. Snd's default interpolation is quite good though, and all operations available for marked and selected areas can be applied to a single sample.

Sinc interpolation is employed by default for Snd's high-quality sample-rate conversion. The sinc width can be set to improve the lowpass filter during conversion, and sinc interpolation can be toggled to linear interpolation for lower-powered machines.


Snd provides an "unlimited" undo/redo function. Snd's Edit History panel (see Figure 4) provides another way to undo/redo and compare edits: Simply click on any listing in the panel, and the channel graph immediately displays that particular edit stage. Very sweet.

Varispeed and other real-time controls

From the main menu, click on View/Show Controls. A set of sliders and other control widgets will unfold beneath the active file's channel graph display (see Figure 2-04). All of the sliders work in real time: The amplitude and speed controls are always active, the others are toggled on or off by a checkbox to the right of their displays. Select Options/Hidden Controls to open a bank of sliders to fine-tune some of the effects parameters [Figure 5]. In case you were wondering, the icon to the right of the speed slider is a pair of arrows (<-->) for toggling playback direction, in real time of course.

Screen shot.
Figure 5. The hidden controls

Real-time response was quite smooth for most of the effects. High values for the reverb scaler tended to distort the sound, and the Contrast effect was particularly sensitive. Time compress/expand and pitch-shifting performed smoothly over a looping playback (an ideal setup for the musician trying to learn a difficult passage from a recording), and within reasonable scaling limits the reverb was equally responsive.

Filtering and envelope editing

Snd provides two graphic filter editors, one below the default control panel display and one in the Edit menu. Several pre-defined filters are also available in the Effects menu.

Pull up the control panel's sash from its default position to uncover a frequency response envelope editor for an arbitrary-order (even-numbered) FIR filter. Plot your envelope points, set the order of the filter by clicking the tiny increment/decrement buttons to the right of the data box labeled "filter:", then press Apply to filter the active sound file. Judge the results, and undo as necessary and repeat the process until you're satisfied.

Select Edit Envelope from the Edit menu to open another graphic editor [Figure 6]. This one is more general purpose: You can create linear or exponential envelopes for amplitude (amp), frequency (flt), and sample rate conversion (src), and you can apply them to the whole file or just to the selected area. The frequency response envelope is applied to an arbitrary-order FIR or FFT filter, the exponentiation factor can be adjusted (with the slider labeled "exp:"), and envelopes can be named and saved to files for later use.

Screen shot.
The envelope editor

The Effects menu includes a variety of pre-fabricated filters. Butterworth filters are available in band-pass, band-reject, high-pass, and low-pass configurations; two comb filters are on the menu; and there's even a Moog-style lowpass-filter (24db/oct) with variable Q. More filters and filter parameter controls are available via the Listener, and work proceeds to bring more of that code into the Effects menu and the graphic control widgets.

Reverb and other effects

We have already seen the real-time reverb controls available on Snd's control panel. The algorithm employed for that reverb is from composer Michael McNabb's Nrev, and it can now be called from the Effects menu with more of its parameters exposed. Composer John Chowning's reverb also produces a good sounding reverb with only two controls.

Convolution is an excellent means of applying a natural reverberation to a sound file. The process typically requires a sound file to be effected and an impulse response (IR) file to supply the effect. IR files are recordings of very brief sound events such as a finger-snap or a firecracker in an interesting acoustic environment. When a sound file is convolved with an impulse response file, it will sound as though it had been originally recorded in that environment. Snd's "simple" convolution is surprisingly effective, and I had great fun reverberating sound files with impulse responses from subway stations, stone cathedrals, and gigantic gas tanks. I also rediscovered the value of the Normalize amplitude scaler: The convolution produced a sound file with a greatly expanded dynamic range, but normalizing scaled the data back to the range comfortable for my 16-bit audio device.

The Effects menu includes other common signal-processing routines such as flange, echo, and time-scaling/pitch-shifting. It also includes less-common routines such as cross synthesis and adaptive saturation. All of these processing options have been available via the Listener, but the graphic controls invite experimentation without the language learning curve.

Pages: 1, 2, 3, 4, 5

Next Pagearrow

Linux Online Certification

Linux/Unix System Administration Certificate Series
Linux/Unix System Administration Certificate Series — This course series targets both beginning and intermediate Linux/Unix users who want to acquire advanced system administration skills, and to back those skills up with a Certificate from the University of Illinois Office of Continuing Education.

Enroll today!

Linux Resources
  • Linux Online
  • The Linux FAQ
  • Linux Kernel Archives
  • Kernel Traffic

  • Sponsored by: