Written: 2024-04-23
Recreating the original Macintosh boot beep
A while ago, I saw a video of the original Macintosh beep extended beyond its usual one-second length[a]. Curious commenters asked how it was done, and as it turns out, the original assembly code has been released by one of the programmers who worked on the original Macintosh's boot ROM[b].
[a] Macintosh startup sound extended
[b] Folklore.org: BootBeep routine
The poster ported it to C and increased the number of loop iterations to get a longer sound. Unfortunately, that code hasn't been released.
So I ported it again myself.
After some failed attempts at understanding how it works exactly (and a lot of fighting the compiler's automatic type conversions) I just kept the original register names for the variable names, and most of the interesting comments.
The C code only outputs raw samples to stdout, and an external shell script plays it using aplay. The original Macintosh's "audio system" was just a beeper timed using the video signal, so after some fumbling around and some calculations, it turns out to be an 8-bit PCM at 22.25kHz.
It can be played with:
mbeep | aplay -q -f U8 -r 22250