Project 11: DTMF (Touch-Tone) Decoder (The Listener)

Build a decoder that detects telephone keypress tones from audio.


Project Overview

Attribute Value
Difficulty Level 2: Intermediate
Time Estimate Weekend
Main Language C
Alternative Languages Python, Rust, C++
Knowledge Area Tone detection and classification
Tools Audio files with DTMF tones
Main Book “Understanding Digital Signal Processing” by Richard G. Lyons

What you’ll build: A decoder that identifies which telephone keypad digit was pressed based on the dual-tone signal.

Why it teaches DSP: It is a real classification task built on frequency detection and thresholding.

Core challenges you’ll face:

  • Isolating two simultaneous frequencies
  • Handling noise and variable tone duration
  • Mapping detected frequencies to digits

Real World Outcome

You will input audio with touch-tone sequences and output the detected digits in order.

Example Output:

$ ./dtmf_decode --input dial.wav
Detected: 4 1 3 9 7 0

Verification steps:

  • Compare detected digits to known sequences
  • Test with tones at different amplitudes

The Core Question You’re Answering

“How can I reliably detect two tones at once and map them to a keypad symbol?”

This project shows how DSP becomes pattern recognition.


Concepts You Must Understand First

Stop and research these before coding:

  1. DTMF frequency pairs
    • What are the low and high frequency groups?
    • Book Reference: “Understanding Digital Signal Processing” by Richard G. Lyons, Ch. 13
  2. Frequency detection
    • When should you use a small DFT vs a Goertzel algorithm?
    • Book Reference: “The Scientist and Engineer’s Guide to DSP” by Steven W. Smith, Ch. 10
  3. Thresholding
    • How do you decide a tone is present vs noise?
    • Book Reference: “Understanding Digital Signal Processing” by Richard G. Lyons, Ch. 6

Questions to Guide Your Design

  1. Detection method
    • Will you compute a short DFT for each tone window?
    • How will you set the analysis window size?
  2. Decision logic
    • How will you prevent false triggers during silence?
    • What minimum duration qualifies as a valid tone?

Thinking Exercise

Frequency Table

Write down the standard DTMF frequency pairs for digits 1, 5, and 9. Then explain why two tones are used instead of one.

Questions while working:

  • Why choose frequencies that are not harmonically related?
  • How does dual-tone reduce errors?

The Interview Questions They’ll Ask

Prepare to answer these:

  1. “What is the Goertzel algorithm used for?”
  2. “Why does DTMF use two frequencies per digit?”
  3. “How do you choose window size for tone detection?”
  4. “What thresholds prevent false positives?”
  5. “How would you handle noisy or clipped tones?”

Hints in Layers

Hint 1: Starting Point Start with clean, synthetic DTMF tones to validate detection.

Hint 2: Next Level Use small windowed transforms to measure target frequencies.

Hint 3: Technical Details Check for one strong tone in each band and map to the keypad.

Hint 4: Tools/Debugging Plot the short-time spectrum to verify tone presence and duration.


Books That Will Help

Topic Book Chapter
Tone detection “Understanding Digital Signal Processing” by Richard G. Lyons Ch. 13
Goertzel algorithm “The Scientist and Engineer’s Guide to DSP” by Steven W. Smith Ch. 10
Thresholding “Understanding Digital Signal Processing” by Richard G. Lyons Ch. 6

Implementation Hints

  • Start with a small set of digits to simplify validation.
  • Keep analysis windows fixed and test with different durations.
  • Log detected frequency magnitudes to tune thresholds.

Learning Milestones

  1. First milestone: You can detect tones for a single digit reliably.
  2. Second milestone: You can decode sequences with minimal errors.
  3. Final milestone: You can explain why DTMF design is robust.