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') &
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
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
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| 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 |
Enter to Win an Adafruit Pi Cobbler Breakout 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 Pi Cobbler Breakout 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
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




1 hour 11 min ago
1 hour 28 min ago
3 hours 22 min ago
5 hours 15 min ago
12 hours 9 min ago
12 hours 25 min ago
14 hours 16 min ago
20 hours 8 min ago
1 day 40 min ago
1 day 41 min ago