PC speaker
From Wikipedia, the free encyclopedia
The PC speaker is the most primitive sound system used in IBM compatible PCs, and in fact used to be the only one in use in PC games before more technologically advanced sound cards such as AdLib or the Sound Blaster were introduced as ISA plug-in cards in the late 1980s. However, even some years after these sound cards became mainstream and widely used, game manufacturers continued to support PC-speaker-only sound/music in their games in order to maximise their customer base. This was in part due to the fact that sound cards did not originally follow any commonly agreed-upon standard and were largely incompatible with each other, whereas the PC speaker was the only sound system that could be regarded as universally present.
The PC speaker is best characterized by its inability to play more than one tone at once, the waveform being generated by the Programmable Interval Timer. Because of this, it was often nicknamed a PC beeper or PC squeaker, especially when sound cards became widely available. In spite of its limited nature, 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-1990s, using swift arpeggios. Several programs, including MP (Module Player, 1989), ScreamTracker, Fast Tracker, Impulse Tracker, and even a Microsoft Windows device driver, could play Pulse-code modulation (PCM) sound through the PC speaker using special techniques explained later in this article. 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 completely on faster PCs (that is, significantly faster than the program was originally developed for).
All modern operating systems include a generic sound API, so that applications no longer need to know the specifics of each sound card. Correspondingly, the use of high-quality sound hardware has become commonplace. As a result, the PC speaker today deals mainly with low-level warning signals such as start-up errors. Regardless, the speaker's interface has remained the same and as such can still be utilized (as long as it hasn't been reduced to an onboard miniature piezo speaker, whose acoustic properties are significantly different from the older paper cone speakers such that most of the more complex sound generation techniques no longer work).
[edit] Pulse-Width modulation
The PC speaker is normally meant to reproduce a square wave via only 2 levels of output, 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), it is possible to drive the speaker to various output levels *in between* the two defined levels. This effectively allows the speaker to function as a crude DAC, thereby enabling approximate playback of PCM audio. This technique is called Pulse-width modulation (PWM) and is notably used in class D audio amplifiers.
Getting a high fidelity sound output out of this technique requires the switching frequency between the minimum and maximum sound levels to be 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 the output devices' dynamic range and power (e.g. by making a loudspeaker vibrate in both directions). On the PC speaker, however, most of these conditions don't hold; for example, the physical properties of the speaker lacks the response time for such high rates, and the output voltage is either zero or TTL level (unipolar). As a result, the precision of this technique when used on the PC speaker is comparable at best to a 6 bit PCM DAC, while the final audio results will depend on precise timing and the nature of the reproduced sound.
The audio fidelity of this technique will be further decreased by the lack of a properly sized dynamic loudspeaker, typical of modern machines and particularly laptops, that use a piezoelectric speaker. 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, something which a normal dynamic loudspeaker can do on its own right, while a piezoelectric speaker will let most 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.)
[edit] See also
[edit] External links
- Site for old PC without sound cards.
- GameDev.net article on programming the PC Speaker.
- Part 1 of another article about programming the PC speaker.
- Part 2 of the article
(includes a very detailed explanation of how to playback PCM audio on the PC speaker, and why it works)