oreilly.comSafari Books Online.Conferences.


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

Screen shot.
Figure 7. Popup menu for the frequency-domain display.

Spectral view

Snd's frequency analysis displays are impressive. Your sound file can be analyzed by any of nine transforms, with more than a dozen window types and sizes. The spectral view itself can be controlled by the keys of your numeric keypad: The arrow keys control the perspective, the forward slash and asterisk keys control the transform size, and the plus and minus keys adjust the analysis window's "hop" size. The keypad Enter key resets the analysis defaults. You can also control the resolution of the x axis by left-clicking on the axis display and dragging the mouse to zoom in and out of the analysis data. Many other options are available from the frequency graph pop-up menu [Figure 7] or from Options/Transform Options on the main menu bar.

32-bit file support and file format conversion

Snd correctly reads and displays 32-bit sound files, automatically scaling the output for 16-bit audio equipment. I tested Snd's 32-bit capability by using Csound to create two 32-bit files -- one in IRCAM's SF format and the other as a WAV file. Both sound files loaded and played without complaint.

You can convert the sound file's format with File/Save As. That dialog includes selection boxes for header style and data representation (with default associations), an entry box for comments, and the default sampling rate (user-definable).

Plug-in support and dynamically loaded modules

If Snd is configured --with-ladspa, you can dynamically load LADSPA plug-ins (see my article on LADSPA plug-ins on the O'Reilly Network). Unfortunately Snd does not yet provide graphic controls for LADSPA plug-ins, but loading them via the Listener is not terribly difficult. Here's a basic example:

(apply-ladspa (make-sample-reader 0) (list "cmt" "delay_5s" .3 .5) 12000 "/home/dlphilp/soundfiles/bunt.wav")

This sequence tells Snd to read a block of 12,000 samples from the bunt.wav file, starting at sample number 0, and apply the delay_5s LADSPA plug-in (found in the library) with a delay time of .3 seconds and a 50/50 balance of unaffected and affected sound.

File playback and recording

Play commands are available everywhere in Snd. The Play button toggles playback from the start of the file; when toggled off, the cursor returns to its original position. Normal play and loop play are available for the whole file, highlighted selection, or marked area. The channel graph pop-up menu includes commands for normal play (from the start of the file), play from cursor position, play previous edit, and play the original unedited file. Use synch marks for multichannel play as described above. Press the space bar to pause playback, press again to continue playback from the stop point. Type C-t to stop the player at any time, or select Stop Play from the Panic Control menu created by the customization package.

Snd will load and play monaural, stereo, and multichannel soundfiles in 8-, 16-, or 32-bit resolution. If your audio hardware supports true multichannel playback, Snd will distribute the channels properly, but it will also nicely fold multichannel files into stereo output if the hardware is not capable of handling more than two channels. You can also make a multichannel sound file by specifying the desired number of channels when creating a new empty file from the File/New dialog.

Recording with Snd

Go to File/Record to open Snd's Recorder window [Figure 8]. In this window, you can monitor and record audio input, set system sound levels, and save your recordings in a variety of file formats. You can specify a file name for your recording, along with its sample rate and number of channels, and if necessary, you can adjust the record buffer size.

Snd's default input device is the microphone channel of the system sound card mixer. To change the recording device, close the Recorder and make this entry in the Listener:

(set! (recorder-in-device) mus-audio-line-in)

Reopen the Recorder and the input channel will now be set to the line-in of your sound card mixer. To set the input channel back to the microphone, close the record window and run this command in the Listener:

(set! (recorder-in-device) mus-audio-microphone)

Replace microphone with cd to record from your CD player. Or you can skip all that typing by using a widget I put together for my SBLive (found in the Special menu), but you'll still need to open/close the Recorder window to reset the input device.

The instructions above are valid for ALSA, OSS/Linux, and the kernel drivers. However, if you're using the ALSA drivers you have an extra record input option: You can tap the sound card mixer's master output as a recording source, letting you record the output from programs like Freebirth (a cool synth/sample-player/sequencer with, alas, no file-save function), or from Internet streaming audio broadcasts. This Listener command correctly informs the Recorder to take its input from the soundcard mixer's master output:

(set! (recorder-in-device) mus-audio-line-out)

It will not reset the system mixer, because Snd is slightly out of synch with the current ALSA packages. Any ALSA-aware mixer should include a switch to set the master output as the record source, and hopefully Snd's support for native ALSA features will improve after ALSA reaches version 1.0. Until then, ALSA's OSS emulation layer works perfectly for Snd compiled with support for the OSS/Free (kernel sound) API.

Note: As mentioned earlier, Fernando Lopez-Lezcano has been working to improve Snd's support for native ALSA. Snd does support ALSA 0.5.x and 0.9.x beta, though your mileage may vary according to your particular sound card. See the documentation in the latest Snd packages for the latest information regarding Snd and ALSA.

Once you've selected your recording device, you can set its level from the mixer in the top-right corner of the Recorder window. When you are satisfied with the level settings, activate the Recorder's input channels by pressing one or both of the A/B buttons beside the input level meters. Now give your recording a new name and press the Record button. When you've finished, press the Done button (it replaced Record). If you toggled the Autoload button, your new file will be loaded immediately after recording.

You can also start recording only after the input signal passes a certain level. When you move the Trigger slider, the Record button becomes a Triggered Record button: press it, but no recording will occur until the input level reaches the amplitude set by the threshold slider.

Snd's recording facilities are rather Spartan, but Snd was not designed to replace a hard-disk recording system. The Recorder is a useful tool, and if your recording needs are not particularly heavy, it may suit your purpose perfectly.

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: