Editor's note: In part one of this two-part series on sound editing under Linux, Dave Phillips shows how you can move over from Windows-based Cool Edit to Linux-based Snd. He compares the two software packages, then moves into the installation and configuration of Snd. In part two, Dave will walk you through a Snd tutorial and show you some advanced sound-editing techniques.
A sound file editor (also known as an audio editor) is one of the standard tools of the digital sound and music trades. Audio editors work on sound files in ways that are analogous to the actions of text and graphics editors upon their respective file types. Typically a modern sound file 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 and click is the expected mode of user interaction.
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?".
Cool Edit [Figure 1] is perhaps the most popular sound file editor available for the Windows OS family. It has been in continuous development for more than 10 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).
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.
For various reasons, it has been rather difficult to advise Cool Edit users on a Linux equivalent. While there are many sound file 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).
Table 1: Supported platforms
Windows 95/98/ME, NT/2000, or higher
DEC Alpha, SGI, HP-UX, mkLinux, Linux, PPC, SCO, Solaris
Like Cool Edit, Snd has been in lengthy development. Snd author Bill Schottstaedt has programmed Snd continuously since 1996, but his involvement with writing sound file 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.
The differences and similarities between Cool Edit and Snd led me to many considerations regarding interface design and its necessary tradeoffs. Cool Edit's interface is uniformly designed for editing and processing sound files. 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 CCRMA, 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.
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, the developer can customize the program's appearance and behavior, warping it into quite a different Snd, something more like Cool Edit but definitely still Snd.
What installation and configuration tips do you have for new Snd users?
This article describes how such a warping can 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 ongoing 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 sound file editor, and I consider Cool Edit Pro to be more of a multitrack hard-disk recording environment. So with this understanding, let's get into Snd...
To build the version of Snd presented in this article, you will need to install the following support software:
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.
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.
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:
rpm -ivh snd-5-1.ppc.rpm
will install the LinuxPPC package (you will probably need root status to install the RPM file).
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.
To build Snd yourself, first download the source package (currently
snd-5.tar.gz) from the CCRMA Snd Home Page 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), sound card driver support (ALSA, OSS, Esound), the use of Ruby instead of Guile for Snd's extension language, and support for LADSPA plug-ins. I use the following command options to compile Snd:
./configure --with-motif --with-ladspa --with-static-xm
This configuration builds Snd with a Motif 2.1 GUI, support for the LADSPA audio plug-ins, 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.
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
Snd is also available via CVS. Please see the Snd home page for the details of accessing and downloading using CVS.
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 ALSA 0.9 beta6), 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
sound card, Snd's ALSA support may not be in synch 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.
Note: Fernando Lopez-Lezcano has recently hacked a workaround 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.
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 OpenMotif 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.
Here are the hardware specifications of the system used throughout this article:
System software includes Linux kernel 2.4.5 patched for low-latency (for more information please see my article about setting up the Linux kernel for low-latency published by the O'Reilly Network) and the sound card drivers from ALSA 0.5.11. I built the ALSA package with the OSS emulation enabled and Snd is quite content with that arrangement.
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.
Start Snd by entering
snd 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.
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.
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).
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 vi 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:
Press the spacebar to pause playback; press it again to continue playback from the pause point.
The following key combinations provide more precise cursor movement:
These particular movements are especially valuable when zoomed into a file to single-sample resolution.
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 do plan to provide graphic controls for positioning the cursor.
Both Cool Edit and Snd can be customized, but in Cool Edit's case, the extent is limited to interface cosmetics, audio system configuration settings, and support for plug-in architectures (though this support is very powerful). Snd is vastly more extensible, and it is by means of that extensibility that we will find a gentler and perhaps more familiar way into the depths of Snd. And yes, Snd also supports a plug-in architecture (LADSPA). Let's take a closer look at how we can customize Snd to make it friendlier to Cool Edit users.
Snd's functions can be customized and extended by means of three files: the
.snd initialization file, the
Snd.ad X resource file, and Scheme code (files with the
.scm extension) loaded at runtime or dynamically loaded during program operation (via the Listener window). Some customization options are also available at the command-line when launching Snd. The resource and initialization files can both contain Scheme code, but I suggest placing lengthy code within its own file or files.
I use my
$HOME/.snd initialization file (included in the
dp_scm tarball listed in the Resources for this article) to define the cursor shape, set display colors, restrict file listings to sound file types only, and set some audio parameters. This file also stores the information generated from selecting Save Options from the Options menu.
An X/Motif program such as Snd may utilize a resource file that defines various aspects of the Motif graphic interface such as color sets and font lists. The Snd distribution contains a resource file named
Snd.ad (the extension stands for "application defaults") that should be copied simply as
Snd to your
$HOME directory. There isn't much to edit in
Snd.ad, and you can safely leave it as it's found in the source package.
The source distribution includes a large collection of
.scm files. These Scheme code files are the keys to accessing Snd's full range of capabilities, including routines for signal processing and other special effects and for adding new features to the graphic interface (such as menus and graphics control widgets). We will return to these files throughout this article, and we will investigate some of them in detail, but for now let's continue with our introduction to the basics of Snd.
Here's how I typically open Snd:
snd -geometry 900x800 -l /home/dlphilp/my_scm/misc.scm foo.snd foo.wav foo.au foo.sf2 foo.mp3 foo.W01
The format extensions to those
foo files should be familiar to most audio people (the last one is a file format for the Yamaha TX16W sampler) and Snd will dutifully load them all. The MP3 and sampler files are converted to the RAW and Snd formats respectively, but the conversions work only for importing sounds: Snd does not encode MP3 files nor can it directly write files in the TX16W format (see Table 2 for a full list of Snd's accepted file types).
Table 2: Supported file formats
MPEG 3 (MP3), ACM waveform (WAV), Apple AIFF format (PCM encoded data only) (AIF), CCITT mu-Law and A-Law waveforms (WAV), Dialogic ADPCM (VOX), IMA/DVI ADPCM waveform (WAV), Microsoft ADPCM waveform (WAV), Next/Sun CCITT mu-Law, A-Law and PCM format (AU), Raw PCM Data, Sound Blaster voice file format (VOC), TrueSpeech (WAV), ASCII Text Data (.TXT), Amiga IFF-8SVX (.IFF, .SVX)
RealMedia G2 (export only)
read/write (many data formats):
NeXT/Sun/DEC/AFsp, AIFF/AIFC, RIFF (Microsoft WAV), IRCAM (old style), NIST-sphere, no header (RAW)
read-only (in selected data formats):
8SVX (IFF), EBICSF, INRS, ESPS, SPPACK, ADC (OGI), AVR, VOC, PVF, Sound Tools, Turtle Beach SMP, SoundFont 2.0, Sound Designer I and II, PSION, MAUD, Kurzweil 2000, Tandy DeskMate, Gravis Ultrasound, ASF, PAF, CSL, Comdisco SPW, Goldwave sample, omf, quicktime Sonic Foundry, SBStudio II, Delusion digital, Digiplayer ST3, Farandole Composer WaveSample, Ultratracker WaveSample, Sample Dump exchange, Yamaha SY85, SY99, and TX16, Covox v8, SPL, AVI
automatically translated to Sun 16-bit, then read/write:
IEEE text, Mus10 SAM 16-bit (modes 1 and 4), IBM CVSD, AVI, NIST shortpack, HCOM, Intel and Oki (Dialogic) ADPCM, MIDI sample dump, G721, G723_24, G723_40, IFF Fibonacci and Exponential
automatically translated (with appropriate Scheme module) to 16-bit 44.1 kHz stereo RAW, then read-only:
-l flag informs Snd that a Scheme file is to be loaded along with the rest of the program's normal functions. I utilize several Scheme files from the Snd source package to customize the program with such amenities as an effects menu, various time-domain and frequency-domain editing routines, and other significant interface extensions and enhancements.
Multiple instances of this flag may be entered at the command line, but one Scheme file can
#include other Scheme files by using the
load command. For example, my
misc.scm file begins by including some of the distribution Scheme files as well as some custom code for my own extensions:
(load "/home/dlphilp/snd-5/snd-motif.scm") (load "/home/dlphilp/snd-5/examp.scm") (load "/home/dlphilp/snd-5/dsp.scm") ... (load "/home/dlphilp/my_scm/special-menu.scm") (load "/home/dlphilp/my_scm/new-effects.scm")
Other lines in this file will turn on a "hidden controls" dialog, check for unsaved edits before exiting Snd, summon a panel for listing and editing marks, and add many other features available from the Scheme files loaded above. We'll look more closely into
misc.scm later, but for now it is important to note that before using my
misc.scm to customize Snd you must edit the load path to indicate where you have unpacked the Snd sources.
-geometry flag is an X Windows option to set the size of any X-aware application and is not unique to Snd.
Snd's graphic display can also be configured using the
-horizontal flags. The notebook flag will present your sound files as though they were on pages in a tabbed spiral-bound notebook [Figure 3], while the
-separate flag will open the files in separate windows [Figure 4]. Snd's normal graph view stacks multiple sound files in a vertical fashion, but the
-horizontal flag will place them side by side [Figure 5].
Finally, opening Snd with the
--help flag will result in this display of information:
[dlphilp@localhost dlphilp]$ snd --help Snd is a sound editor. Peruse the 'help' menu or try the snd-help function for help. This is Snd version 5.2 of 30-Aug-01: Xen: 1.0, Guile: 1.5.0 OSS 3.9.8 Sndlib 13.7 (29-Aug-01, int24 samples) CLM 1.51 (6-July-01) gsl: 0.9.1 Motif 2.1.30 X11R6 Xpm 3.4.11 with LADSPA Compiled Aug 30 2001 09:40:29 C: egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) Libc: 2.1.3.s
Figure 6 shows how my customized Snd appears with one sound file loaded and its time-domain and frequency displays both opened. The marks panel and edit history list are active, and I have also opened the Listener and the Control Panel. Note that you can open or close any sashed panel by grabbing and moving the sash key. Note also the menus added to the main menu bar: the Special, Marks, and Panic Control menus are not standard with Snd, I have added them via my customization files.
Scheme is a LISP-like programming language and Guile is its interpreter. Files written in Scheme are processed by Guile and the results returned to Snd. We have seen what such files can add to Snd, so now let's take a look inside a Scheme module to see how it works. We'll use excerpts from my
misc.scm file for our example: The file is too long to quote entirely, but I have placed the complete text of
misc.scm online for interested readers. It is also included in my Snd customization package listed in the Resources at the end of this article.
We know already that
misc.scm starts by loading a variety of other Scheme files. Immediately after those files are loaded, I make the following calls to them from within
(title-with-date) ;;; puts the filename and date in the xterm titlebar, ;;; from examp.scm (keep-file-dialog-open-upon-ok) ;;; keeps the file dialog open after clicking on OK, ;;; helpful when loading many files, from snd-motif.scm (make-hidden-controls-dialog) ;;; places the Open Hidden Controls entry in the ;;; Options menu, from snd-motif.scm (check-for-unsaved-edits #t) ;;; checks for unsaved edits before closing, ;;; from extensions.scm (add-hook! after-open-hook show-disk-space) ;;; reports available disk space to the minibuffer, ;;; from snd-motif.scm (add-mark-pane) ;;; adds the mark panel automatically after the ;;; first mark is created, from snd-motif.scm (add-sound-file-extension "W01") ;;; adds the sound file extension W01 (for ;;; Yamaha TX16W sampler files) to Snd's internal list ;;; of recognized file formats, from extensions.scm
These lines demonstrate how to customize Snd using Scheme modules from the source distribution. The actual functions are defined in other pre-loaded Scheme files but are called from
misc.scm. Many of Snd's most interesting features are defined throughout the source package's various Scheme files but they are not activated by default. Much of my preparatory work involved studying the various Scheme modules to find what treasures they contained.
This code actually adds a new function to Snd and a new entry to an existing menu:
;;; -------- Cut selection -> new file (define (cut-selection->new) ;;; give the function a name (if (selection?) ;;; if there is a selection (let ((new-file-name (format #f "sel-~D.snd" selctr))) ;;; make a new filename numbered by selctr (set! selctr (+ selctr 1)) ;;; increment selctr (save-selection new-file-name) ;;; save the selection with the new filename (delete-selection) ;;; cut out the selection (open-sound new-file-name)))) ;;; open the new file (add-to-menu 1 "Cut Selection -> New" cut-selection->new) ;;; add "Cut Selection -> New" to menu number 1 ;;; (the Edit menu)
Misc.scm can itself act as a holder for Scheme code activated elsewhere. I added this brief block in order to add an
Unselect function to Snd:
;;; -------- Deselect function (define (deselect-all) ;;; name the new function (if (selection?) ;;; if there is a selection (set! (selection-member? #t) #f))) ;;; negate its existence (reset its state ;;; from true to false)
However, I placed the call in Snd's
popup.scm for placement in the channel graph display pop-up menu.
These examples indicate how I have gone about customizing Snd. I began by making sure that the baseline features as enumerated by Curtis Roads (and listed in the next section of this article) were present and easily accessible, then I added functions and operations suggested by the responses to my query to Cool Edit users. I must emphasize that I myself wrote virtually no code (well, maybe a wee tiny bit): as stated earlier, my objective has been to make more of Snd's inherent processing and editing power more visible and accessible to users, and thanks especially to the routines in
snd-motif.scm I believe I'm well on the way to meeting that objective.
Other Necessary Software
Dave Phillips maintains the Linux Music & Sound Applications Web site and has been a performing musician for more than 30 years.
Return to the Linux DevCenter.
Copyright © 2009 O'Reilly Media, Inc.