What this covers


The built in pseaker, not the sound card.  This is reprogramming something that was just supposed to go "beep".
 

The Speaker Control Chip

It's a 8254 programmable time chip.  I've never heard of it.  But....
It's interrupt is tied to interrupt #7 of the CPU (not listed in /proc/interrupts).  The int7 goes off at a rate controlled by this coounter.
ioport 41h is the ram refresh.  Mess with this and you die!
ioport 42h is the speaker output
ioport 43h is a programable register on the timer chip.
All these ports are unsigned 16 bit values.

The Timer Chip

Has a basic operating frequency of 1,193,180Hz which is 1/4 the standard NTSC frequency.  By loading a value into counter1, the associated timer will go off every 1,193,180/value seconds.  If value == 0, then the timer will go off every 18.2Khz.

Sound

Sound is analog.  Normally, you would make sound by running the data through a DAC chip, and then to a speaker.  But we can only produce one bit digital.  And not some cool step function, just "yes" or "no".  Therefore our sound is going to be less good than a sound card.

1 BIT DAC

The hardware CANNOT produce the waveform we're looking for, nor anything like it.  But what's imporant it that the speaker make the right moves, not the electronics.  We send a very high frequency pulse to the speaker.  It takes a position that is the average value of this set of voltages.  To make sound, we vary the frequency, and the position changes.  If we vary the frequency fast enough, but not too fast, then the speaker will vibrate and make sound.