LinuxDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


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

A look at my Snd

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.



Inside a scheme file

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 misc.scm:

(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.

Resources

Online Resources:

Other Necessary Software

Print Resources

  • Dodge, C., and Jerse, T. A. Computer Music: Synthesis, Composition, And Performance. New York: Schirmer, 1997. Perhaps the best introduction to the subject. See the material in chapter 10.3, "Modification Of Sampled Sound".
  • Phillips, D. The Book Of Linux Music And Sound San Francisco: No Starch Press, 2000. Includes a chapter on sound file editors for Linux, with a profile of Snd.
  • Roads, C. The Computer Music Tutorial. Cambridge: MIT Press, 1996. The definitive tome; see especially the material in chapter V.16, "The Musician's Interface".

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.




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.java.net
  • Linux Kernel Archives
  • Kernel Traffic
  • DistroWatch.com


  • Sponsored by: