When I started building an online Morse code translator, I assumed the hard part would be the alphabet. Map letters to dots and dashes, done. I was wrong. The alphabet took an afternoon. The timing took weeks.

Here's the thing nobody tells you about Morse code until you actually try to generate it: it's not really an alphabet. It's a rhythm. And rhythm is brutally unforgiving to get wrong in code.

The bug that wasn't a bug

Early on, my translator worked fine for something short like SOS. But longer sentences sounded... off. Not broken exactly, just slightly wrong in a way that was hard to describe. I compared it against real recordings of amateur radio operators sending CW, and the difference was obvious once I heard it side by side: my dashes were too short relative to my dots, and my word gaps were inconsistent.

It turned out I'd been treating "dot" and "dash" as separate arbitrary durations I could tune by ear, instead of treating them as ratios of a single base unit. That's the actual rule, standardized internationally as ITU-R M.1677-1: