DEV Community

Tender Wound Care
Tender Wound Care

Posted on Edited on

Morse Code Audio Decoder: How Software Turns Beeps Into Text

Decoding Morse from a recording sounds simple: find the beeps, measure them, look up the letters. In practice most of the work is in the first step. If you want something to test against while reading, a browser-based Morse decoder will show what each stage produces.

1. Find the tone

A Morse signal is a single tone, usually somewhere between 500 and 1000 Hz. Decoders run a filter (a Goertzel filter is cheap and common) tuned to that frequency and track its energy over time. Everything else in the audio is noise.

2. Turn energy into on and off

The filter output is compared with a threshold. Above it the key is "down", below it the key is "up". A fixed threshold breaks as soon as the volume changes, so good decoders adapt it to the recent signal level.

3. Measure the timing

Morse timing is relative, not absolute:

  • dot = 1 unit, dash = 3 units
  • gap inside a letter = 1 unit
  • gap between letters = 3 units
  • gap between words = 7 units

The decoder estimates the unit length from the shortest marks it hears, then sorts every mark and gap into these buckets. At 20 words per minute one unit is about 60 ms (1200 / WPM).

4. Look up the letters

Once the marks are grouped into letters, it is a plain table lookup: .- is A, -... is B, and so on.

Why real recordings fail

  • Hand-sent Morse drifts in speed, so a fixed unit length goes wrong mid-message.
  • Radio static adds false short marks that look like dots.
  • Two signals on close frequencies confuse a wide filter.

Top comments (0)