You used to be able to do surprising things with those old speakers using a timer interrupt: on an IBM XT it was possible to get 8kHz quality out of it, enough to make 4-channel MOD playback sound about as good as hearing it over a phone.
But your more typical use case was to play a single tone for some significant fraction of a second.
The 8088 MPH demo, for example, pushed the PC Speaker pretty far: https://www.youtube.com/watch?v=yHXx3orN35Y
This was on a 386, not an XT, but I had a shareware driver for Windows 3.1 that provided that for the regular Windows sound APIs.
Yes, a friend of mine had a Turbo Pascal library (aka unit) that he used as alternative when no sound card was available, for his games.
I remember an old company called "Access software" that had something called "Realsound" with which they played really high quality audio on the PC speaker. Their games were things like Countdown, Martian Memorandum etc.
Mach 3 by Loriciels (France) from 1987 is impressive in this regard:
https://www.youtube.com/watch?v=chJrd9Kxbdw
It somehow sounds even better on an actual 80s PC, with the bass sound being amplified by the massive steel enclosure.
[dead]
Nice, there’s also a great in-depth article about an album driven entirely using the primitive PC speaker. The whole COM file comes in at around 40 KB, so you can copy it onto an old machine and run it. Some of it you'd swear you're listening to a SID chip~
https://habr.com/en/articles/439192
https://www.youtube.com/watch?v=tUy1MEpqbvk