Author: Jion Kubo Date: 26.04.2025 GitHub: https://github.com/kubojion Contact: kubojion@gmail.com License: MIT License
This project implements a simple and effective DTMF (Dual-Tone Multi-Frequency) tone decoder. It detects the sequence of keypad tones from an input audio file using FFT analysis and dynamic threshold skipping to avoid repeated detections.
The algorithm is designed to work on clean or moderately noisy audio signals and can handle standard telephone DTMF tones.
The project consists of two MATLAB files:
-
run_dtmf.m: Main demo script to load an audio file, call the decoder, and display results.
-
decode_dtmf.m: Function that performs DTMF tone detection from the given audio signal.
- MATLAB (any version supporting basic functions like fft, audioread, inputParser)
- No toolboxes required
- Reads a .wav audio file (mono recommended).
- Selects only the first channel if stereo.
- Analyzes short overlapping frames using FFT.
- Identifies peaks at known DTMF frequencies.
- Applies thresholding to decide if a button is pressed.
- Dynamically skips frames while the tone remains active to avoid double-counting.
- Outputs the detected sequence of keys.
- Place your
.wavfile (recorded DTMF tones) in the same folder. - Open
run_dtmf_demo.mand modify theaudioFilevariable to your file name. - Run
run_dtmf_demo.min MATLAB. - The console will display detected keypad sequence.
Audio file: output_audio.wav Sampling rate: 44100 Hz Window length: 2048 samples Detected keys: 1234567890#
Optional parameters in decode_dtmf.m:
-
'AmplitudeThreshold' (default 1e-3) Minimum spectral amplitude for detecting a tone.
-
'SkipFraction' (default 0.8) Fraction of detected peak magnitude used for dynamic skipping.
You can also manually change the FFT window length (Nw) by editing the helper function chooseWindowLength(fs).
- If fs > 44100 Hz, window size = 8192 samples (for higher frequency resolution)
- Otherwise, window size = 2048 samples (better time resolution)
Feel free to adjust Nw if you encounter very fast or very slow tone sequences.
- Mono audio is recommended. Stereo files will use only the first channel.
- Works best with sampling rates around 44100 Hz or 48000 Hz.
MIT License
This project was initially developed for a university project in DFT signal analysis and was extended for general DTMF detection.