Sound Through the PC-Speaker
Linux supports most of the popular sound cards. If you don't have a sound card, you can still get a degree of sound support from the humble speaker that came with your PC. In this article, I will discuss one way of obtaining sound output without a sound card.
PC-Speaker is a driver for the modest sound output device that comes standard with most (perhaps all?) IBM PC clones. It is installed as part of the kernel or as a loadable module; either way, the kernel needs to be changed. PC-Speaker comes with a small set of programs to use with it—I have compiled these programs on my system without trouble.
The driver comes as a patch file, which must be applied to the Linux source directory (/usr/src/linux). When make<\!s>config is run after applying the patch, it will ask whether you want PC-Speaker support—answer “yes”. Give the commands:
make depend; make clean; make zImage
and your new kernel will be ready. The patches to the source include some header files for /usr/include/sys, which are necessary to make the utilities that accompany the driver.
The driver supports the following devices :
/dev/pcsp: The raw data device
/dev/pcaudio: The SUN-audio device
/dev/pcmixer: The mixer-device
I have /dev/pcsp only defined on my machine:
crw--w--w- 1 root root 13, 3 Aug 27 20:25 /dev/pcsp
The program pcsel sets options for PC-Speaker and is used to configure the /dev/pcsp device at system startup and to test new devices. You can also assign an output device to /dev/pcsp using the pcsel program. The supported output devices are:
Stereo-on-One (designed by Mark J. Cox), which is auto-detected during kernel startup and selected by default.
PC-Speaker, which is selected if Stereo-on-One was not found.
Mono DAC, which is for one lp-port.
Stereo DAC, which is for two lp-ports.
Listing 1. Help Output from pcsel
Specifying the help option on the pcsel command line:
$ pcsel -help
gives you a listing of all the pcsel options and what they mean. With no options specified, pcsel reports the actual output-device and its parameters in this way:
$ pcsel PCSP driver version 1.0 Actual PCSP output device: PC-Speaker Volume : 100 %, real samplerate : 18356 Hz Maximum Samplerate is 51877 Hz 16bit Stereo Emulation enabled
These two programs, vplay and vrec, can be used for recording and playing the following types of files:
Creative Labs voice files
Microsoft wave files
raw audio data files
Both programs accept the same options, which can be listed by specifying the help option:
vplay --help
The output of this command is shown in Listing 2.
Okay, confession time—the main reason I had for adding this driver to my kernel was to have sound effects in Doom. Here is another trivial example of what you can do with PC-Speaker. I have a directory of .wav and .au files. This shell script, called from my .profile file, plays one of these audio files at random each time I log in.
#!/bin/sh
# random-sound.sh: play a random file from the
# sounds directory
export count="`ls sounds/*|wc -l|sed s/ //`"
export count=`expr $count + 0'
(1>/dev/null 2>&1 vplay `echo sounds/*| \
awk BEGIN{srand()}{x=1+int(rand()*number)
print $x} number=$count') &
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Home, My Backup Data Center
- What's the tweeting protocol?
- Readers' Choice Awards
- New Products
- RSS Feeds
- Linux on Azure—a Strange Place to Find a Penguin
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




9 hours 14 min ago
11 hours 47 min ago
13 hours 4 min ago
13 hours 39 min ago
14 hours 1 min ago
18 hours 50 min ago
19 hours 37 min ago
21 hours 10 min ago
22 hours 47 min ago
1 day 45 min ago