A developer shows how to coax high-quality PCM from the ZX Spectrum’s tiny 1-bit beeper by using tightly timed software pulses. The technique was proven on real hardware (a 48K Spectrum and an Omni 128 rebuild) and in multiple emulators (Fuse among others). Results sound markedly better than a naive PCM player, but remain limited in practicality: output is very quiet without an external amplifier and long samples consume almost all available RAM. Tight cycle-counted code in Z80 assembly was required because timing and register pressure made higher-level languages impractical.
Early attempts failed: a straightforward pair of delay loops produced only an audible 8kHz whistle, and a dynamic computed-jump into long NOP streams yielded only a faint trace of the sample. Instrumenting Fuse’s audio output revealed transition times of roughly 97-170 microseconds, showing that speaker inertia and decay matter as much as rise time. The successful approach uses very short pulses (turn on, run 0-15 NOPs, turn off) - roughly 18-78 CPU cycles - and implements each pulse-length case with macro-generated code and a jump table instead of fragile self-modifying patches. That cycle-exact dispatch delivers clear 1-bit PCM, and the writeup compares this approach to other compact engines such as Dmitry Milk’s demos and RTSynth.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.