Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

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

cordially
Posted
Updated 10-Jan-18 7:27am
v3

See these?:
http://sourceforge.net/projects/dtmf/[^]
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en536955[^] (this one is for PIC processors but the algorithms might be available in C)

Found another Java implementation:
http://henryranch.net/software/java-dtmf-detector/[^]
 
Share this answer
 
Comments
RandSirpi 18-Jul-12 12:18pm    
Hello,

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+.

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

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.

Sincerely,
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.
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: http://paulbourke.net/miscellaneous/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: http://www.tapiex.com/ToneDecoder.Net.htm[^]
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: http://www.tapiex.com/TDNet_Help/[^]

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: http://www.youtube.com/watch?v=6XvWRzWzgNI[^]

You can also try this: http://msdn.microsoft.com/en-us/library/ff827802.aspx[^]
 
Share this answer
 
v2
Of course, because of the Shannon-Nyquist theorem, you'd have to compare at least two detected frequencies next to each other and only leave the one with the loudest tone in.
Maybe run an iteration over it beforehand and erase the more silent tones next to each other.
You could probably even better only detect the exact frequencies of the 4x4 matrice and don't run a complete detection over the spectrum.
I know that it was sloppy.
But two tests showed that it still worked. At least with no disturbing noise around it.
I'll explain it: if you let echo a tone with the amplitude of the slope on every signal position ( next value versus previous is the amplitude of the sinus wave echoed on that position) and repeat that over several signal positions, if the echoed tone is in the signal, there will be an amplification. Otherwise, other tones will not be amplified but blocked. Ever noticed that when you sing along with the pitch in which a string is tuned, that it will start to ring? Also, besides octaves, fifths, fourths and after that major thirds upwards will also be activated, but less loud. Because of that fact, you could accelerate the detection recursively if you started some octaves higher and only hangled down if the amplitude was over a threshold.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900