Click here to Skip to main content
13,004,203 members (74,516 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I try to find a method in C/C++ or C# to detect a sound (DTMF code) from a microphone in Windows. Currently, I can not find a simple method (FFT off and acoustic fingerprint) to know what is a DTMF sound. Would you know if there are libraries (with examples to understand) or an effective method to get there. I look with Microsoft TAPI to see without knowing how to use it.

With C#, I found the DTMFrecognitionEngine on MSDN but I did not find examples to understand how it works.

I want a simple method for now in order to realize such a simple demonstration.

If someone has an idea, I am interested

Posted 18-Jul-12 5:20am
Updated 18-Jul-12 5:29am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

See these?:[^][^] (this one is for PIC processors but the algorithms might be available in C)

Found another Java implementation:[^]
RandSirpi 18-Jul-12 12:18pm

thank you for these addresses,

I knew that of sourceforge (there is a version in C # and another in Java in addition to the C++) but I did not understand how a sound, he could convert DTMF code.

For jDTMF, I had used to understand the theory but I have not been unable to find the code to understand and offer a version in C# or C+.

Albert Holguin 18-Jul-12 12:55pm
So what you're asking is how the whole technology works?
RandSirpi 19-Jul-12 6:14am

yes, I try to understand how even a pseudo-code how to make a recognition code of the DTMF key telephone keypad. I understand the theory but do not how to achieve. I thought to play a sound, try to break a two-frequency sound to know its high frequency and low frequency but I do not know how.

Albert Holguin 19-Jul-12 10:38am
Well, the gist of it is that you have to take the audio samples (PCM) and do an FFT on them. The FFT will give you a frequency domain representation of the signal, from there, you need some sort of "detection" algorithm that will identify the peaks within the audible tone range (just under 4kHz range). There's various ways of doing the detection portion and that's up to the implementation.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

This article explains how to implement a 1D FFT - How to implement the FFT algorithm[^]

For simplicity, I would suggest you try with a DFT first. The processing may be slow, but its much simpler to implement. This page contains both a description and a code listing of both FFT and DFT:[^]

The simplest peak detection method is finding values above the mean of all samples and looking for changes in slope. Copying this from another post:

Between any two points in your data, (x(0),y(0)) and (x(n),y(n)), add up y(i+1)-y(i) for 0 <= i < n and call this T ("travel") and set R ("rise") to y(n)- y(0) + k for suitably small k. T/R > 1 indicates a peak. This works OK if large travel due to noise is unlikely or if noise distributes symmetrically around a base curve shape. For your application, accept the earliest peak with a score above a given threshold, or analyze the curve of travel per rise values for more interesting properties.


For simplicity I would recommend using a ready-made library over trying to write the whole algorithm. I would stick to C# over C++.

Try this:[^]
It can easily decode DTMF from an Audio file or a stream, which is what I assume you are after.

They have some help files here:[^]

From their manual:
PhoneToneDecoder decode variant of tone signals such as DTMF, Caller-ID, TTY, SAME etc.
There are three ways to feed the audio data to this component.
From the file (.wav, .mp3, .raw etc).
Stream data capture by WaveEx control
Stream data feed by manually via WaveStreamInput method.


What you can also do is record the WAV file then decode it. I have had good success using the NAudio library with C# earlier. The library also has functions to compute the FFT.
Consider this tutorial series:[^]

You can also try this:[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170627.1 | Last Updated 27 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100