DEV Community

Dev Nestio
Dev Nestio

Posted on

Morse Code Converter — Text to Morse with Web Audio Playback

Overview

Morse Code Converter encodes text to Morse code and decodes Morse back to text, with real audio playback.

🔗 https://devnestio.pages.dev/morse-code/

Features

  • Text → Morse: all letters (A–Z), digits (0–9), punctuation
  • Morse → Text: decodes dot/dash sequences; / for word breaks
  • Audio playback via the Web Audio API with smooth tone fade-in/out
  • Adjustable WPM: 5–40 words per minute (PARIS standard)
  • Visual flash: indicator pulses in sync with audio
  • Reference table: all 36 character codes visible at a glance

Example

SOS → ... --- ...
HELLO WORLD → .... . .-.. .-.. --- / .-- --- .-. .-.. -..
Enter fullscreen mode Exit fullscreen mode

Tech: sample-accurate audio scheduling

Timings use the Web Audio API scheduler rather than setTimeout, giving sample-accurate playback:

gain.gain.linearRampToValueAtTime(0.5, t + 0.005);    // fade in
gain.gain.setValueAtTime(0.5, t + dur/1000 - 0.005);  // sustain
gain.gain.linearRampToValueAtTime(0, t + dur/1000);   // fade out
Enter fullscreen mode Exit fullscreen mode

Dot duration = 1200 / WPM ms (PARIS standard). Dash = 3× dot. Letter gap = 3× dot. Word gap = 7× dot.

👉 Try it: https://devnestio.pages.dev/morse-code/

Top comments (0)