The speaker in the original IBM PC is nearly the worst electronic musical instrument ever created. This isn’t because amazing works of art were never created for the PC speaker; no, that’s been done, and it’s amazing. The PC speaker is terrible because of how limited it is. It does one note at a time, only square waves, driven by an 8253 Programmable Interval Timer. Polyphony? Forget about it. Volume control? Nope. These aren’t really shortcomings, because music is art, and you can write a novel without using the letter ‘E’; the trick is in how you manage to do it.
[shiru8bit] took a deep dive into the PC speaker and decided to make an album. The video, with the completely necessary CRT graphic display, can be seen here. This alone is impressive, but what makes it amazing is how this album happened.
If you want to play more than a simple melody on a PC speaker, there are two or two and a half ways to do it. The first is to (virtually) set up two (or more) channels, loaded up with frequency values. At set intervals, the CPU changes the 8253 to output one frequency, then in the next chunk of time, sets the 8253 to another frequency. It sounds ‘bubbly’ for lack of a better term, but the results can be amazing; just check out the PC speaker version of Monkey Island. The 8253 can also be turned into a rudimentary DAC, but this was a rare technique thanks to patents, and by the time the patents expired everyone already had a Soundblaster. Oh well.
[shiru8bit]’s album uses the first technique, cycling through monophonic square waves at 120 Hz, but the real trick here is how the individual channels were composed. This required creating a VSTi plugin called PCSPE. This emulates a PC speaker, and sort of, kind of, implements arpeggios, pitch, and priority of different channels. Effectively, it’s a PC Speaker tracker.
The result is classic chiptune goodness, made on an instrument that really shouldn’t be used for music. It can be played on DosBox, but the weirdness of the real hardware including transients and the inefficiencies of a tiny speaker make real hardware almost a necessity here. You can check out the entire album below.
The 48K ZX spectrum’s speaker is also just a single bit on or off and the clever programmers of the day managed to create the music in the link below.
https://www.youtube.com/watch?v=u-D24A_N4d4
Tim Follin rulezzz!
Tim Follin does rule! – here is another one of his:-
https://www.youtube.com/watch?v=T42WuUpBuHE
Is my browser acting up ? Both links posted by kryptolemese appear as ads for FindChipsPro and just go to their page ….
I still use the PC speaker. Since it’s not on the motherboard I have to connect my own. In Linux Mint it’s turned off by default. So I turn it on and use it in programs and scripts to alert me to something that is happening since my DAC connected stereo is not always on. In the terminal use the beep command: beep -f 659 -l 460 -n
The Sol-20 microcomputer didn’t have any audio, but there was an add-on card which provided it very simply. The interrupt enable line, which is on the S-100 bus, was not used by the Sol. The card simply took that signal, sent it through a low-pass filter and a small op-amp and there was your audio. That little 2.04 MHz 8080 could produce this:
https://www.sol20.org/media/d-minor.mp3
This is an amazing album, but where is a CRT display? All I can see is an old laptop, with a 90-s style LCD screen.
The PC Speaker audio driver from Win3 worked well enough to listen to polyphony audio
The Apple II was also 1 bit and could generate music and even sound bytes (Ghostbusters always comes to mind)
“mumble GHOSTBUSTERS! MAHAHAHAHA”
Yep, the 48K Spectrum did sound bites too:-
https://www.youtube.com/watch?v=y0cb9LmH-Xo
I seem to remember in the days before I had a sound card, downloading Star Trek sound effects that played through the PC speaker.
I was looking for a quick example, but I suspect that may have been using the PWM trick.
Basically, you use 2 timers, one that triggers an ISR and the one that is connected to the PC speaker but changed to one shot mode. The ISR loads the one shot value into the other time effectively setting the duty cycle for that period. The frequency of the first timer triggering the ISR becomes the base PWM frequency.
While watching this I feel like I should be installing a pirated copy of something.
At the end of the day, if you can turn a bit off and on quickly enough you can reproduce “analogue” sound very accurately. This is what Class D (Digital) amplifiers do and the link below details an example with <.03% from 1W to 600W @ 8Ω ( in the listening range) and 22 kHz):-
http://www.spectronaudio.com/musicianIII.htm
How much does the THD improve if you also install their cryogenically treated special fuses?
For that matter, the DSD modulation employed by SACD is a single bit, turned on and off at several MHz, and then filtered. You can do a lot with one bit.
But to the PC speaker itself, look up an old modplayer called Galaxy, I believe version 2.12 was the last released:
ftp://ftp.scene.org/mirrors/hornet/music/programs/players/00_index.txt
Galaxy will not only play a 4-channel MOD over the PC speaker at a respectable mixing frequency, it’ll do a real FFT (not the fake bouncing-bars common in its era) and display the results in its textmode display. Grab a few MODs to play with it, just start with this one if you’re new to the format: https://modarchive.org/index.php?request=view_by_moduleid&query=42560
Back in the early 90s I wrote an article for the PCGPE showing how to set up the PIT in order to play raw PCM samples through the PC speaker. Both my writing style and my understanding of sampling theory were somewhat limited at the time, but it gives a reasonable explanation of how it was achieved:
http://www.gamers.org/dEngine/rsc/pcgpe-1.0/speaker.txt
Sadly, DosBox doesn’t appear to support interrupt-on-terminal-count mode. :(
There are 3, maybe 4 tracks on this album that are more than a collection of random farting noise :/ And yes, I did play PC games in early nineties.
The PC speaker driver for Windows 3.1x was of limited usefulness because it brought everything else to a halt while playing audio. I don’t recall of the same driver worked in Windows 95 or if it was a different driver, but Win 95 could use the PC speaker driver while continuing to run everything else.
I remember way back in the day IBM had a demo disk that actually synthesized speech through the PC speaker. Sure it was garbled and hardly worth the trouble but it was cool back then. There is also PC speaker ‘beep’ music to toy/annoy with https://github.com/ShaneMcC/beeps
There was a Windows driver available for Win 3.x that would allow you to play mono sound to the PC speaker. It didn’t multitask well, and everything else would pause whilst the sound played. I remember using it before I got a Soundblaster 16.
It couldn’t multitask at all with Win 3.1x. With Windows 95 it could play PCM sound through the PC speaker without stopping everything else.
It COULD multitask, there was a tickbox option. The result was whining and clicking through your sample playback. Without that, though, it was pretty good.
sounds BA on my Zenith 286 laptop
“Polyphony? Forget about it.” — NOT QUITE
Polyphony on a PC speker has been done, and I replicated the algorithm in Java, and notived that with minor tweaks I can extend the algorithm to change the sound volume and pulse width, with ease. Originally called winplay and was made in Russia. http://annex.retroarchive.org/cdrom/chst-win-01/SOUNDS/WINPLAY/index.html Source included.