The ZX Spectrum had a small speaker, but the only way to “drive” it was a single bit on one of the Z80 I/O ports. By sending zeroes and ones at an appropriate rate you could get a musical note. Pretty basic square wave stuff.
Someone somewhere had the thought that if you sent ones and zeroes REALLY fast, and not in a regular pattern, something other than a boring square wave note could be produced. Effectively it was possible to use simple math to “mix” multiple notes, send the complex pattern of ones and zeroes to the CPU I/O port and you would “hear” two notes at once.
A notable example of this was a product called “Wham! The Music Box”
When I was massively into Z80 programming Amstrad had launched the PC1512 and PC1640 machines, PC compatibles with an 8 MHz 8086 CPU, and as I had access to a PC1640 I started collecting a magazine dedicated to the machine.
On one particular issue was a cover disk and a program called Pianola, which used the same clever trickery to make the 8 MHz Amstrad PCs produce 4 channel sound on their speaker, which was as basic as the speaker in the ZX Spectrum and controlled basically the same way.
Shortly afterwards there was a followup, where the program’s author explained the format of the music files (which I had already worked out) but also HOW it worked complete with 8086 source code.
By this time I felt I was pretty handy with Z80 code, and knowing a little 8086 too I felt I could “port” the code over to my 3.5 MHz machine and I thought I could squeeze THREE channels out, because I felt that in certain respects the Z80 was sometimes a little more efficient, with that sort of code and techniques.
Well I was right, and I got reasonably clear three channel sound on a 3.5 MHz Z80 powered ZX Spectrum, based on code I “found” and ported from an 8 MHz 8086 powered Amstrad PC.
I then pushed my luck, putting in a fourth channel, and unfortunately my “code loop” slowed down into audible frequency range producing a high pitched whistle, so dropped myself back to three channels.
Sadly I have EXTREMELY little source code from this era, and do not have any of this source now.
Likewise I also do not have my Z80 code for the 256 by 64 pixel silky smooth scrolling text banner, running at 50 FPS, still on that 3.5 MHz chip in the ZX Spectrum without any visual tearing. Let’s just say THAT was down a certain amount of loop unrolling and vertical blank timing, and only JUST moved 2K of memory before the TV scan reached the text. I saw a commercial slideshow/demo for a game with maybe 24 or 32 pixel high text and thought I could do better.
Hmmm, I was obviously an arrogant little sod at times!
EDIT:
I’ve found a few links referencing the original “Pianola”. There is a “trick” to downloading the RAR archives, click on the little downwards pointing arrow at the right, not the filename – the download links given after you do that do not work. Sadly no source for the player in these archives – I believe an article accompanying one of the following issues only had partial code, and sadly no longer to hand. Mind you, the entire player is only a “.COM” file and under 2K… What was it for .COM? Raw binary with ORG 0100h?
https://sites.google.com/site/kevinphair/old-pc-cover-disks/pca/88-07
https://sites.google.com/site/kevinphair/old-pc-cover-disks/pca/88-09
https://sites.google.com/site/kevinphair/old-pc-cover-disks/pca/88-12
https://sites.google.com/site/kevinphair/old-pc-cover-disks/pca/89-01