<html>
<body bgcolor="#FFFFFF">

<center><h3>Developing And Using Snd</h3></center>
<center><h4>A Simple Guide And Tutorial For Editing Sound Under Linux</h4></center>
<center><h4>by</h4></center>
<center><h4><a href=mailto:dlphilp@bright.net>Dave Phillips</a></h4></center>
<p>

<u><b>INTRODUCTION TO SOUNDFILE EDITORS</b></u>
<p>

A soundfile editor (aka an audio editor) is one of the standard tools of the digital sound and music trades. Audio editors work on soundfiles in ways that are analogous to the actions of text and graphics editors upon their respective file types. Typically a modern soundfile editor includes the common cut/copy/paste routines along with a complement of signal processing and mixing modules. A graphic interface and waveform display is usually encountered (though text-mode audio editors do exist for UNIX/Linux), and point & click is the expected mode of user interaction.
<p>

As Linux grows in popularity among artists working in media such as audio/video and animation we can expect to see more interest in the system's audio capabilities and its available sound and music software. Sound workers migrating from Windows or the Mac will look for tools similar to what they have enjoyed using on their previous platforms, and one of their most frequently asked questions is "What Linux audio editor will most completely take the place of Cool Edit ?". 
<p>

<a href=http://www.syntrillium.com/cooledit/>Cool Edit</a> [Figure 1] is perhaps the most popular soundfile editor available for the Windows OS family. It has been in continuous development for more than ten years: programmer David Johnston originally wrote Cool Edit as shareware for Windows 3.1, and in 1995 the Syntrillium corporation began managing the commercial development of the program (the company still maintains and distributes the shareware version available on the Internet).
<p>

<center> <img src="images/jpg/1_01-ce2000.jpg">
<p>
<b>Figure 1.</b> Cool Edit 2000 (courtesy Dmitri Touretsky)
</center>
<p>

Cool Edit is a wonderful program. Its interface is easy to navigate and invites experimentation with a powerful editing and processing toolkit. I used it extensively from its earliest versions through Cool Edit 96, and when I finally stopped using Windows Cool Edit was one of the few programs I truly missed. 
<p>

For various reasons it has been rather difficult to advise Cool Edit users on a Linux equivalent. While there are many soundfile editors available for Linux none are up to Cool Edit's standard, particularly with regards to transparency and ease of use. In response to this challenge I decided to work on extending and enhancing Snd, a powerful audio editor for Linux and other UNIX platforms (see Table 1 for a complete list).
<p>

<pre>
********************************
*                              *
* Table 1: Supported platforms *
*                              *
********************************

   Cool Edit: Windows 95/98/ME, NT/2000, or higher

   Snd: DEC Alpha, SGI, HP-UX, mkLinux, Linux, PPC, SCO, Solaris, *BSD, Mac OSX
</pre>
<p>

Like Cool Edit, Snd has been in lengthy development. Snd author Bill Schottstaedt has programmed it continuously since 1996, but his involvement with writing soundfile editors dates back to the late 1970s when he wrote the Dpysnd audio editor for the PDP-10 minicomputer. However, Snd's user interface and other basic design differences are problematic for Cool Edit users, and it is easy to miss Snd's great power and utility. I decided to expose more of that power to the novice and to try to create a working environment similar to Cool Edit. This article will relate how that work has been accomplished so far and will indicate the work that remains.
<p>

The differences and similarities between Cool Edit and Snd led me to many considerations regarding interface design and its necessary trade-offs. Cool Edit's interface is uniformly designed for editing and processing soundfiles. Almost every action and function in the program can be accessed and controlled by the mouse, and users can navigate their way through the entire program by pointing and clicking. Thanks to this uniform interface a novice easily learns and remembers the program's behavior and more quickly moves into actually working with the program. On the other hand, Snd has been designed to function within a rich sound processing and music composition software environment developed at <a href=http://www-ccrma.stanford.edu/>CCRMA</a>, Stanford University's Center for Computer Research in Music and Acoustics. That environment includes the Common LISP Music (CLM) sound synthesis language, the Common Music (CM) scoring tools for CLM and other output formats (such as Csound and MIDI), and the Common Music Notation (CMN) package. Indeed, Snd could be considered as a graphic display front-end for CLM: the standard build incorporates CLM as a built-in module, Snd provides a window called the Listener for entering code to access the module's synthesis and processing functions, and the interface provides various ways to play and represent the newly synthesized sound. 
<p>

In contrast to the uniformity of Cool Edit, Snd's user interface could be thought of as "multiform" by design. In the default GUI the mouse is extensively employed, but far more program control is available through Snd's Emacs-style keyboard commands. And while considerable processing power lurks under its surface access to that power has been restricted to users willing to learn the necessary scripting language. Thus, in order to use Snd to its fullest potential the user must learn to manage Snd's more complex control interface and acquire some proficiency in the Guile/Scheme language. With that proficiency he can customize the program's appearance and behavior, warping it into quite a different Snd, something more like Cool Edit but definitely still Snd. 
<p>

This article describes how such a warping has been achieved by a user with very little programming skill (I'm really a musician) and virtually no experience with LISP or Scheme. It is not a shoot-out between Cool Edit and Snd. It is actually a status report of an on-going project to externalize Snd's great internal power, using Cool Edit as a model for developing Snd's user interface. I must also note that Cool Edit 2000 has been my measuring rod, not its bigger brother Cool Edit Pro: I have focused on Snd's utility as a soundfile editor, and I consider Cool Edit Pro to be more of a multitrack hard-disk recording environment. So with this undertanding let's get into Snd... 
<p>


<u><b>GETTING STARTED WITH SND</b></u>
<p>

<b>Requirements</b>
<p>

To build the version of Snd presented in this article you will need to install the following support software:
<p>

<pre>
  Guile 1.5.x
  OpenMotif 2.1
  ALSA 0.9.x with OSS emulation enabled
  LADSPA and its various plugins
  the Scheme customization files included in the snd-5/contrib/dlp directory
</pre>
<p>

See the Resources section for the download locations for these packages. It is beyond the scope of this profile to give instructions on installing this software, but the documentation for each package will lead you through their respective build and install procedures. Any other requirements should be fulfilled by libraries and other software included in most mainstream Linux distributions. 
<p>

The ALSA driver packages are not strictly required. You can build Snd perfectly well with either the kernel sound modules (aka OSS/Free) installed or with the excellent OSS/Linux commercial drivers from 4Front Technologies.
<p>

<b>Getting It, Building It, Installing It</b>
<p>

Prebuilt binaries for Linux i386, LinuxPPC, and Sun are available from the Snd home page. Source and binary RPMs have been prepared and are available for the i386 and PPC Linux versions. To install Snd from those packages simply follow the usual method of installing RPMs. For example, this command:
<p>

<pre>
	rpm -ivh snd-5-1.ppc.rpm
</pre>
<p>

will install the LinuxPPC package (you will probably need root status to install the RPM file).
<p>

<i>Note: The instructions and descriptions throughout this article refer to Snd built for the i386 architecture. I was unable to test my build configuration on any other system, but I would like to hear from anyone running Snd on other platforms, particularly LinuxPPC.</i>
<p>

To build Snd yourself first download the source package (currently snd-5.tar.gz) from the <a href=http://www-ccrma.stanford.edu/software/snd/>CCRMA Snd Home Page</a> to your home directory. Unpack it with 'tar xzvf snd-n.tar.gz' (where n is the major version number), then enter your newly created snd-n directory and read the README.Snd file for the latest installation instructions and details. Run './configure --help' for a list of configuration options: This list includes options for your choice of user interface (Motif, GTK, none), soundcard driver support (ALSA, OSS, Esound), the use of Ruby instead of Guile for Snd's extension language, and support for LADSPA plugins. I use the following command options to compile Snd:
<p>

<p>
<pre>
	./configure --with-motif --with-ladspa --with-static-xm
</pre>
<p>

This configuration builds Snd with a Motif 2.1 GUI, support for the LADSPA audio plugins, and built-in support for the graphics routines within Snd's Motif module (xm.so, if built separately). Default values are accepted for all other configuration options, including Snd's default support for the OSS/Free kernel sound API.
<p>

After configuring the build, run 'make' and wait for the compiler to finish building your new Snd. Become superuser (su root) and run 'make install'. The binary will be installed in /usr/local/bin and a manual page will be placed in /usr/local/man/man1. 
<p>

Snd is also available via CVS. Please see the Snd home page for the details of accessing and downloading using CVS.
<p>

<!--
<b>Why Not Native ALSA ?</b>
<p>

My build configuration includes Snd's default support for the OSS/Free kernel sound API. Including the --with-alsa option will build Snd with native ALSA support (either 0.5.x or the 0.9.x beta series), but the state of the ALSA API is rather mercurial at this time (though quickly closing in on its long-anticipated 1.0 release). Depending on your soundcard, Snd's ALSA support may not be in sync with the most current API. Running Snd with ALSA 0.5.11 native support for my SBLive Value crashed the program when trying to record, but the same driver package works perfectly (via ALSA's OSS/Free emulation mode) with Snd compiled for OSS support. However, native ALSA support and OSS emulation both worked fine for my SB PCI128. I also encountered no problems with recording or playback using the OSS/Linux drivers.
<p>

<i>Note: Fernando Lopez-Lezcano has recently hacked a work-around that allows recording in Snd under native ALSA with my SBLive. Preliminary tests indicate that the hack works well with mic, line, and CD input, but it is problematic recording from my mixer's master output channel. Hopefully a complete solution will be found soon, and I should emphasize that Snd's ALSA support is already quite functional.</i>
<p>
-->

<b>Why Motif Instead Of GTK ?</b>
<p>

Snd can be configured for a build using either Motif or the GTK graphics libraries or for a build with no GUI at all. Some users may wonder why I chose to build Snd with Motif instead of the more modern GTK. As a matter of fact I did build Snd with GTK a few times, but I prefer the amenities of Motif, particularly the keyboard acceleration. More importantly, my interface enhancements depend on the xm.so module. Work proceeds on bringing the GTK version to the same level of customization as the Motif build, but it's not there yet. A final consideration was the fact that Motif 2.1 is now freely available from the <a href=http://www.opengroup.org/openmotif/>OpenMotif</a> group, while the well-known LessTif (replaces Motif 1.2) is also available for free and is usually included with most mainstream Linux distributions. However, Snd may exhibit some odd behavior with LessTif, and author Bill Schottstaedt has indicated that he would rather not bother with Snd + LessTif problems, so I recommend the OpenMotif package.
<p>

<b>The Test System</b>
<p>

Here are the hardware specfications of the system used throughout this article:
<p>

<pre>
        800 MHz AMD Duron
        512 MB memory
        two 15 GB Maxtor IDE hard-disks
        Voodoo3 video card with 19" monitor
        SBLive Value and SB PCI128 soundcards
</pre>
<p>

System software includes Linux kernel 2.4.5 patched for low-latency (for more information please see my article about <a href=http://linux.oreillynet.com/pub/a/linux/2000/11/17/low_latency.html>setting up the Linux kernel for low-latency</a> published by the O'Reilly Network) and the soundcard drivers from ALSA 0.9.0beta10. I built the ALSA package with the OSS emulation enabled and Snd is quite content with that arrangement.
<p>

The reader might notice that the test machine is rather "loaded". Processing digital audio consumes system resources, so for best results you'll want a fast CPU, lots of RAM, a large fast hard-disk, and a good video system, preferably with at least a 17" monitor (multichannel displays quickly eat up viewing area, even on a 19" monitor in high-resolution modes). You can work with Snd with less powerful resources, but your mileage will certainly vary from the test system.
<p>


<b>Firing Up</b>
<p>

Start Snd by entering <i>snd</i> at an xterm prompt. With no command-line options or flags you will see Snd's default opening display [Figure 2]. Cool Edit users will immediately wonder what's going on here. They are accustomed to seeing a complete display when Cool Edit starts, not this rather stark and uninformative box. Expanding the window only opens up a blank grey canvas, nothing like the visual array of icons, meters, and timers in Cool Edit. 
<p>

<center> <img src="images/jpg/1_02-snd_default_open.jpg">
<p>
<b>Figure 2.</b> Snd opened with no soundfiles loaded 
</center>
<p>

Snd has evolved within the UNIX domain, and more pointedly it has evolved in the world of computer music and sound synthesis programming languages running on UNIX machines. Unlike Cool Edit, Snd expects the user to learn and understand how to use an underlying programming language to tap the full extent of Snd's capabilities, and this factor often proves to be the major stumbling point for migrating Cool Edit users. Despite the relative ease of learning the Scheme or Ruby scripting language, users coming from Windows or the Mac simply do not expect to meet with such a requirement for the full use of the software. When a user is already proficient at the task, learning a programming language in order to use an audio editor seems not only a daunting endeavor but a pointless one as well.
<p>

The next formidable block for Cool Edit users is the management of a combined keyboard/mouse interface. As I mentioned earlier, Cool Edit is almost entirely mouse-operated. Text entry is supported, but at almost every point the mouse is the designated input device for selecting files and other data, choosing processing options and other menu items, and even setting data values (with spinboxes, sliders, and other data entry widgets).
<p>

By comparison, the default Snd is far more keyboard-intensive. Emacs users will be pleased to find that Snd's keyboard control is based on the Emacs keyboard layout, but that will be little comfort to Cool Edit users (or to <b>vi</b> adherents like myself). Control and Alt key combinations are normally used to operate the default Snd, and I advise new users to learn at least the following keystroke commands:
<p>

<pre>
  C-a position cursor at beginning of the display
  C-e position cursor at the end of the display
  C-v position cursor at the midpoint of the file 

  C-l moves cursor to mid-display
  C-j position cursor on the next mark

  C-t stop playback
  C-g stop all processing

  C-i sends a report to the minibuffer on the status of the soundfile at the cursor position. 
</pre>

Press the space bar to pause playback; press it again to continue playback from the pause point.
<p>

The following key combinations provide more precise cursor movement:
<p>

<pre>
  C-b move cursor back one sample
  C-f move cursor forward one sample
</pre>

These particular movements are especially valuable when zoomed into a file to single-sample resolution.
<p>

There are many other keyboard controls for cursor movement. Fortunately, most of the other basic operations of the program (opening and closing files, starting and stopping playback, accessing menus and menu items, navigating the display, exiting the program) can be controlled by mouse actions. The new user should have no trouble learning a dozen key combinations, but for the seriously keystroke-challenged I have provided graphic controls for positioning the cursor. 
<p>

</body>
</html>
