PC speaker

From Free net encyclopedia

Revision as of 15:55, 6 April 2006; view current revision
←Older revision | Newer revision→

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. 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 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 -- though it can still be used to its full potential should the need arise (as long as it hasn't been reduced to an onboard miniature piezo speaker, whose acoustic properties are so different from the paper cone speakers of old that most of the usual "tricks" don't sound nearly right).

The PC speaker is normally meant to provide only 2 levels of output (ie. 1-bit sound), through writing to the least significant bit of PC I/O port 61H (61 hexadecimal). However, by carefully timing a short pulse (ie. 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 playback of PCM audio.

This technique is called PWM (pulse width modulation) and is notably used in class D audio amplifiers. Getting a correct sound output out of this technique requires that the switching frequency between the min-max level be much faster than the audio frequencies reproduced, e.g. over 100 KHz switching frequency for a 10KHz audio signal.

However, it is not possible to achieve such high switching frequencies on the PC speaker, and as a result the precision of this technique is comparable to a 6 bit DAC, while the final audio results will depend on precise timing, the nature of the reproducted sound, internal hardware noise, CPU activity, and the exact method used to produce the source audio data. This technique will also not work on modern machines, particularly laptops, that use a piezo 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 piezoelectic 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.))

On some hardware implementations, the same I/O port can be read, providing not only status information but also a rough "recording" of the PC speaker's output or a sort of "white noise" if nothing is being played back at the moment, making for a limited use as a random number generator. However, this doesn't appear to be standard and doesn't work on all implementations.de:PC-Lautsprecher sv:PC-speaker pl:PC speaker

External links