PC speaker explained

PC speaker
Invent-Date:1981
Invent-Name:IBM
Conn1:Motherboard
Class-Name:Use
Class1:loudspeaker built into most IBM PC compatible computers
Manuf1:several

A PC speaker is a loudspeaker built into some IBM PC compatible computers. The first IBM Personal Computer, model 5150, employed a standard 2.25 inch magnetic driven (dynamic) speaker.[1] More recent computers use a tiny moving-iron or piezo speaker instead.[2] The speaker allows software and firmware to provide auditory feedback to a user, such as to report a hardware fault. A PC speaker generates waveforms using the programmable interval timer, an Intel 8253 or 8254 chip.[3]

Use cases

BIOS/UEFI error codes

The PC speaker is used during the power-on self-test (POST) sequence to indicate errors during the boot process. Since it is active before the graphics card, it can be used to communicate "beep codes" related to problems that prevent the much more complex initialization of the graphics card to take place. For example, the Video BIOS usually cannot activate a graphics card unless working RAM is present in the system while beeping the speaker is possible with just ROM and the CPU registers. Usually, different error codes will be signalled by specific beeping patterns, such as e.g. "one beep; pause; three beeps; pause; repeat". These patterns are specific to the BIOS/UEFI manufacturer and are usually documented in the technical manual of the motherboard.

Software

Several programs, including music software, operating systems or games, could play pulse-code modulation (PCM) sound through the PC speaker using special Pulse-width Modulation techniques explained later in this article.

Games

The PC speaker was often used in very innovative ways to create the impression of polyphonic music or sound effects within computer games of its era, such as the LucasArts series of adventure games from the mid-1980s, using swift arpeggios. Several games such as Space Hulk and Pinball Fantasies were noted for their elaborate sound effects; Space Hulk, in particular, even had full speech.

However, because the method used to reproduce PCM was very sensitive to timing issues, these effects either caused noticeable sluggishness on slower PCs or sometimes failed on faster PCs (that is, significantly faster than the program was originally developed for). Also, it was difficult for programs to do much else, even update the display, during the playing of such sounds. Thus, when sound cards (which can output complex sounds independent from the CPU once initiated) became mainstream in the PC market after 1990, they quickly replaced the PC speaker as the preferred output device for sound effects. Most newly-released PC games stopped supporting the speaker during the second half of the 1990s.

Other programs

Several programs, including MP (Module Player, 1989), Scream Tracker, Fast Tracker, Impulse Tracker, and even device drivers for Linux[4] and Microsoft Windows, could play PCM sound through the PC speaker.

Modern Microsoft Windows systems have PC speaker support as a separate device with special capabilities – that is, it cannot be configured as a normal audio output device. Some software uses this special sound channel to produce sounds. For example, Skype can use it as a reserve calling signal device for the case where the primary audio output device cannot be heard (for example because the volume is set to the minimum level, the amplifier is turned off or headphones are plugged in).

In the 1990s, a computer virus for Microsoft DOS named "Techno" appeared, playing a melody through the PC speaker while printing the word "TECHNO" on the screen until filled.[5]

Pinouts

In some applications, the PC speaker is affixed directly to the computer's motherboard; in others, including the first IBM Personal Computer, the speaker is attached by wire to a connector on the motherboard. Some PC cases come with a PC speaker preinstalled. A wired PC speaker connector may have a two-, three-, or four-pin configuration, and either two or three wires. The female connector of the speaker connects to pin headers on the motherboard, which are sometimes labeled or .

4-pin, 3-wire PC speaker pinout[6] [7] ! Pin Number! Pin Name! Pin Function
1-SPSpeaker negative
2GND or KEYGround, or unwired key
3GNDGround
4+SP5VSpeaker positive +5V DC

Pulse-width modulation

The PC speaker is normally meant to reproduce a square wave via only 2 levels of output (two voltage levels, typically 0 V and 5 V), driven by channel 2 of the Intel 8253 (PC, XT) or 8254 (AT and later) Programmable Interval Timer operating in mode three (square wave signal). The speaker hardware itself is directly accessible via PC I/O port 61H (61 hexadecimal) via bit 1 and can be physically manipulated for 2 levels of output (i.e. 1-bit sound). However, by carefully timing a short pulse (i.e. going from one output level to the other and then back to the first), and by relying on the speaker's physical filtering properties (limited frequency response, self-inductance, etc.), it is possible to drive the speaker to various intermediate output levels, functioning as a crude digital-to-analog converter. This technique is called pulse-width modulation (PWM) and allows approximate playback of PCM audio. (A more refined version of this technique is used in class D audio amplifiers.)

With the PC speaker this method achieves limited quality playback, but a commercial solution named RealSound used it to provide improved sound on several games.

Obtaining a high fidelity sound output using this technique requires a switching frequency much higher than the audio frequencies meant to be reproduced (typically with a ratio of 10:1 or more), and the output voltage to be bipolar, in order to make better use of the output devices' dynamic range and power. On the PC speaker, however, the output voltage is either zero or at a Transistor-Transistor Logic (TTL) level (unipolar).

The quality depends on a trade-off between the PWM carrier frequency (effective sample rate) and the number of output levels (effective bit depth). The clock rate of the PC's programmable interval timer which drives the speaker is fixed at 1,193,180 Hz, and the product of the audio sample rate times the maximum DAC value must equal this. Typically, a 6-bit DAC[8] with a maximum value of 63 is used at a sample rate of 18,939.4 Hz, producing poor but recognizable audio.[9]

The audio fidelity of this technique is further decreased by the lack of a properly sized dynamic loudspeaker, specially in modern machines and particularly laptops that use a tiny moving-iron speaker (often confused with piezoelectric). The reason for this is that PWM-produced audio requires a low-pass filter before the final output in order to suppress switching noise and high harmonics. A normal dynamic loudspeaker does this naturally, but the tiny metal diaphragm of the moving-iron speaker will let much switching noise pass, as will many direct couplings (though there are exceptions to this, e.g. filtered "speaker in" ports on some motherboards and sound cards).

This use of the PC speaker for complex audio output became less common with the introduction of Sound Blaster and other sound cards.

See also

External links

Notes and References

  1. Book: IBM 5150 Technical Reference . IBM . 1984 . 1–25.
  2. Book: Rosenthal, Morris . Computer Repair with Diagnostic Flowcharts . Revised . Foner Books . August 2008 . 9 . 978-0-9723801-7-1.
  3. Web site: Bran's Kernel Development Tutorial: The Programmable Interval Timer . 2023-01-23 . www.osdever.net.
  4. Web site: Sergeev . Stas . PC-Speaker PCM driver for Linux . 2009-02-15 . https://web.archive.org/web/20091026062530/http://geocities.com/stssppnn/pcsp.html . 26 October 2009 . unfit .
  5. Web site: Nastasi . Alison . The World's Worst Computer Viruses Illustrated . Flavorwire . 11 September 2021 . en . 2014-07-19.
  6. Book: Ögren, Joakim . The Hardware Book . 1997 . 290.
  7. Book: ASUS P5KPL-AM SE Motherboard manual . ASUSTek Computer Inc. . 2008 . 1-13 . 27 February 2017 . https://web.archive.org/web/20171013012706/http://www.lamals.cz/ceniky/datasheety/motherboard/asus/p5kpl_am_se_manual.pdf#page=22 . 13 October 2017 . dead.
  8. Web site: Leonard . Jim . 2022 . IBM PC Sound Ramblings - The Best Sound You've Never Heard . 2022-08-31 . The Oldskool PC.
  9. Web site: Schlunder . Edward . 2006-11-18 . Resistor/Pulse Width Modulation DAC . https://web.archive.org/web/20170317074148/http://www.k9spud.com/digital-to-analog-converters/resistor-pwm . 2017-03-17 . K9spud Microcontroller Electronics.