PC speaker sound effects

From DoomWiki.org

Chocolate Doom running with emulated PC speaker sound effects.

When Doom was released, digital sound cards had not yet become as ubiquitous as they now are. Therefore, a large number of the computers playing Doom did not have sound cards. As a workaround for this, id Software included two sets of sound effects: alongside each of the digital sound effects that are played on sound cards, there is an equivalent PC speaker sound effect that plays through the PC speaker found on all PCs.

While digital sound effects have the prefix "DS" inside the Doom IWAD, PC speaker sound effects have the prefix "DP". For example, the sound of a pistol firing is stored in the lump named "DSPISTOL"; the corresponding PC speaker sound effect is named "DPPISTOL".

The format is notable in that it was the last WAD lump format to be properly decoded and understood. The Doom source code release did not include the PC speaker code, as it was part of the proprietary DMX sound code that was removed from the source code before its release (evidence of this can be seen in the Heretic source code). As PC speaker sound effects were no longer necessary by this time, little effort was made in properly determining the format.

PC speaker sound effects have a four byte header that is used to specify the length of the sound. That many bytes then follow.

Each byte corresponds to a tone that is played for 1/140th of a second (this corresponds to 4*35, where 35 is the number of frames per second in Doom). The frequency values used are on a musical scale; there are 24 notes per octave, which corresponds to double that of the western musical scale (12 notes per octave). The values are therefore a superset of the western musical scale, with an extra microtone inserted between each note.

Because of this, the frequencies increase exponentially with respect to the byte values. Adding 24 to the value doubles the frequency. A value of 0 causes silence.

The format is an evolution of a previous format in that the sound frequency in hertz is likewise obtained by dividing the constant 1193181 by the given value (this constant corresponds to the frequency of a PC interrupt timer). They can then be played back with a square wave generator.