ATtiny85 on circuit board with 2n2222, pushbutton, usb-c power connector, LED, and speaker.

Custom Compression Squeezes Classic Computer Choruses Into A Tiny Controller

Geeks of a certain vintage will have fond memories of games that were simplistic by today’s standards, but drew one in all the same. Their low fidelity graphics were often complimented by equally low fidelity music being forced through the afterthought of a speaker that inhabited most computers. Despite the technical constraints of the era, these games didn’t just offer gameplay. They told stories, and they were immersive in a way that some would think wouldn’t be relatable to a younger generation.

That didn’t stop [Thanassis Tsiodras] from sharing the classic “The Secret of Monkey Island” with his niece and nephew when they were young. Excited to see his family after a year of separation due to COVID-19, [Thanassis] wanted to give them a handmade gift: The music from “The Secret of Monkey Island” on a custom player. What an uncle!

[Thanassis] could have just recorded the music and played it back using any number of chips made for the purpose, but being a long time software engineer, he decided to take the scenic route to his destination. First, DOSBox was hacked to dump the speaker output into a file. Python, C, and 30 years of experience were leveraged to squeeze everything into the 8 KB storage of an ATtiny85. Doing so was no small feat, as it required that he create a custom implementation of Huffman compression to get the data small enough to fit on chip. And when it fit, but didn’t work, even more optimization was needed.

The end result was worth it however, with the music from “The Secret of Monkey Island” playing in its original form from a speaker driven by the ever so humble but useful 2n2222. [Thanassis]’ site is replete with details too intricate to post here, but too neat to miss. Watch the video below the break for a demonstration.

Continue reading “Custom Compression Squeezes Classic Computer Choruses Into A Tiny Controller”

RF Burns And Exploding PC Speakers: Sophos Looks At The Evidence

Every year in the month of June, someone by the unlikely name of [R.F. Burns] posts a question to the Linux Kernel Mailing List asking whether a Linux kernel module is possible that would blow the PC speaker. It’s fairly obviously a joke, which is why the UK-based anti-virus company Sophos have devoted a light-hearted blog post to it.

The post is an interesting diversion into early PC sounds, when the only hardware guaranteed to be present was a small speaker hooked up to a bit on an output port. The bit could be cycled for square wave beeps, or with a lot of clever manipulation could put out a low-bitrate PWM that delivered almost intelligible sounds including music and voice. They conclude that since the speaker would have been designed to be at the full amplitude of the 5-volt output bit all the time it should be impossible to blow it from software, and we’d be inclined to agree. There’s a remote possibility that some speakers might have a resonant frequency that could be found in software, but we’re not entirely convinced.

Your Hackaday scribe might have spent a while in a university computer lab back in the day trying and failing to write C code that would produce a usable PWM on an XT speaker, but those with long memories might recall the PC speaker driver for Windows 3.1. If you’re a fan of chiptune music there are even entire albums written for this most basic of instruments.

Header image: MKFI, Public domain.

The PC Speaker Lives On As A New Album

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.

Continue reading “The PC Speaker Lives On As A New Album”