[Michael] has a thing for playing audio over beepers using a single bit. He’s done it with the Apple ][ and the IBM PC. This time he turns to the ZX Spectrum. He didn’t get quite as good a result — at least not yet — but he did manage to get some things working. He documents everything, so even though this wasn’t a successful week, there’s sometimes more to learn from reasonable failures than from unreasonable successes.
Of course, the whole thing relies on pulse code or pulse width modulation. Of the two techniques, PWM should produce better results. However, he wasn’t able to get PWM working yet. Some other target computers drive the buzzer through a dedicated hardware timer. However, with the Spectrum, it is all software.
Getting multichannel music was another algorithm, and that makes for an interesting read, too. We are sure next week there will be more, and if you are interested in this sort of thing, going back to some previous weeks will show you a lot more, too.
PCM is, of course, nothing new. Sound output has come a long, long way.

Remember these ZX Spectrum 1 bit sound tracks?
Agent X music Tim Follin 1985 (who was 15 years old at the time):
https://www.youtube.com/watch?v=T42WuUpBuHE&list=RDT42WuUpBuHE&start_radio=1
Chronos music Tim Follin 1987:
https://www.youtube.com/watch?v=u-D24A_N4d4&list=RDu-D24A_N4d4&start_radio=1
Clicked in hope to see someone mentioning Tim Follin
That click noise at the beginning hits me right in the nostalgia ganglion.
I pulled apart the Follins’ Spectrum code for Startip 2 in order to try and port it to the 6502. As far as I can tell, all the timing numbers in it were done by hand, because the different voices interfere with each other; changing the pitch of one voice makes the pitch of the other voices change too, requiring you to tweak the numbers to keep it all in tune. I can’t imagine how they did it.
My 6502 player had different timings all across the board, resulting in it sounding… weird. Here it is playing on a Commodore PET: https://www.youtube.com/watch?v=B_SmzoQJBsQ
If anyone’s interested, I did eventually turn that project into a fully-fledged 3½-voice 1-bit tracker for the PET: https://www.youtube.com/watch?v=iqWJeM2MKt4
Great work getting that far! The timbre is better on the PET than the spectrum.
Another unexpected platform where folks have accomplished impressive things with 1-bit sound and a z80 CPU is the TI-8x series of graphing calculators.
For example, there’s also a very nice polyphonic tracker for the TI-82/83/84:
https://irrlichtproject.de/houston/
On the venerable http://ticalc.org/ (which surprisingly still exists), there are many more historic examples of trackers and drum machines, as well as a 1-bit/11khz wav file player (“playwav”), many with .asm source files for the curious.
The calculators of course had no audio hardware, so all of this was done by bitbanging the serial (“link cable”) port, which, with a 2.5mm-3.5mm barrel adapter, could drive a pair of headphones.
back in the day I did some work on this. I remember filling the spectrum memory with very crunchy music. people were not impressed when I said one day all audio will be digital.
Also, back in the day, (over 40 years ago now) a friend and I wrote some Spectrum assembler using the 1 bit output which ended up in the Beaky and the Egg Snatchers game to provide the sound effects. We also built a virtual speech synthesizer by recording phonemes through the microphone port, sampling the port as fast as possible, and translating arbitrary text into speech.
I wrote a similar routine back then that played 6 voice music. You basically have 6 counters that start counting once you load a value into them. As 0 is reached, counter must invert speaker bit and reload the value. So the value is 1/freq. I think I used IX with offset to load/reload counters. And yes, you have to find the value for each note by experimenting. The sound I got was pretty much the same as in Chronos. I was around 15 too. ;) If you add pwm support you get to control volume, I think I also had fading, but I’m not sure. If you change the number of voices, you got to recalculate note constants. Sweet times… I turned 51 a week ago.
I am shocked that no one has mentioned the genius of Irrlicht Project and his sound routines or YouTube series on the history of zx spectrum music. This is the guy who made Houstontracker!
https://youtu.be/UehhQ2suh2s