Chapter 15. Sound in Linux

Table of Contents

15.1. The ALSA PCM Types
15.2. Mixers
15.3. Players
15.4. Buffering and Latencies
15.5. The JACK Audio Connection Kit
15.6. Hard Disk Recording with Audacity
15.7. Direct Recording and Playback of WAV Files
15.8. Compressing Audio Data
15.9. ALSA and MIDI
15.10. MIDI Playback without a WaveTable Card
15.11. AlsaModularSynth — Synthesizer and Effect Processor
15.12. NoteEdit and MIDI Sequencers

Abstract

Linux offers a wide range of sound applications in various stages of development. This chapter provides an overview of a wide range of applications for various multimedia tasks together with some technical background information. Applications that are not part of the standard installation can be installed with YaST.

15.1. The ALSA PCM Types

As of version 0.9 of the Advanced Linux Sound Architecture (ALSA), the concept for PCM devices was fundamentally modified and expanded. PCM is an acronym for “Pulse Code Modulation” and designates the digital output interfaces when relating to sound cards. The user can influence the way ALSA addresses the sound card by selecting a specific PCM type. The main PCM types are hw and plughw.

To understand the difference between the two types, consider how a PCM device is opened. It must be opened with specific settings for at least the following parameters: sample format, sample frequency, number of channels, number of periods (previously referred to as fragments), and size of a period. For example, an application may attempt to play a WAV file with a sample frequency of 44.1 kHz although the sound card does not support this frequency. In this case, ALSA can automatically convert the data in the plug-in layer to a format supported by the sound card. The conversion affects the following parameters: sample format, sample frequency, and number of channels.

Activate the plug-in layer by selecting the PCM type plughw. If the PCM type hw is selected, ALSA tries to open the PCM devices directly with the parameters required by the application. The complete designator for a PCM device consists of the PCM type followed by a colon, the card number, and the device number, for example, plughw:0,0.

The dmix output plug-in is a recent addition to the PCM types. It allows applications to share access to a PCM device on sound cards that do not support this natively. The complete identifier in this case is plug:dmix. More information about dmix can be found at http://alsa.opensrc.org/index.php?page=DmixPlugin.