The PC speaker is fundamentally a cheap piezo element or a real-er magnetic speaker attached to a GPIO attached to a timer. The most simple thing you could do with it was program the timer to output a square wave. But it was also possible to control it directly as an on/off output, and do various waveforms (including PWM), but it would occupy the whole CPU.