DSPRelated.com
Forums

Detecting DTMF Pulses

Started by Stacy March 6, 2014
On 3/10/14 12:26 PM, clay@claysturner.com wrote:
> > Besides what the others have added, an advantage of using a DFT based approach, is you can use parseval's relation to ensure that when you do detect tones, that most of the energy is in just those tones and not across the whole band. Try running voice through your DTMF detector and see how much spoofing you get.
it's something you have to do in any case (make sure that the energy of the two DTMF tones add to a large portion of the total energy), and while you might call it an "advantage", Clay, i would call it a "restriction". maybe not.
> > Another approach passes the data through a pair of band pass filters. One band covers the row frequencies and the other band covers the column frequences. After each of these two filters you perform a 2nd order LPC analysis which will directly yield the frequency of the row and column tones. A 2nd order LPC is not very complicated. There are some appnotes that cover this process. While some LPC variations on DTMF decoding were patented, some of those patents are now expired. If you are just doing this for yourself, then the patent issue doesn't really matter; if not just for you - be advised.
you can get very sharp 2nd-order resonant filters using parametric EQ filters (the "peaking EQ" filter in the cookbook). it's better than a regular BPF because you can get better rejection of adjacent DTMF tones. and you need 8 of these going simultaneously. with all 8 having their output squared and that LPFed to get simultaneous envelopes on all 8. On 3/10/14 4:19 PM, clay@claysturner.com wrote:
> > Yes, a sliding DFT works with a single bin frequency. You can certainy adapt it to work with 8 bins. You certainly don't need to do the FFT as that is likely more computationaly costly than just 8 DFTS.
that's what Goertzel is, basically. it's running a sliding DFT on just some of the DFT bins.
> The advantage of parseval's that I mentioned earlier is it relates the total energy in the time domain to the total energy in the frequency domain.
and you can do that at least as easily in the time domain. square the signal and pass that through a LPF. so that would be a 9th envelope and it would also guide the thresholds on the other 8. another thing that you would do is apply a little hysteresis on the thresholds (like a Schmidt trigger) to sorta "debounce" the touch-tone buttons. you may also need to run counters during the time that a legit DTMF pair are detected, to define the minimum detect time (again to avoid false positives) and the minimum time between detections.
> In the standard case, you calculate the total energy in the frequency domain by using the two loadest frequencies and comparing that to the total time domain energy. Others have done antispoofing by not only doing DFTS for the 8 row/column frequencies but also at their 1st harmonic frequencies (double the fundamentals). Tones will have little energy in the 1st harmonic bins whereas voice often does. > > You can do envelope detection with a Hilbert method, but it may be simpler to do by simply rectifying the signal (absolute value it) and feed that to an attack/decay function (fast attack - slow release). > > > > Very simple example - perform as iteration > > 1) M=M*gamma > 2) if (|X|), then M= |X| > 3) compare M to a trigger threshold > > M is a memory element, and X is the current signal value. gamma is a decay factor; try something like 0.998
this is applied to the envelopes, right? however those envelopes are derived, right?
> > > Since this is a personal project, there are lots of things for you to experiment with.
like using other simpler resonant filters (tuned to the DTMF frequencies) rather than the Goertzel filter. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Mon, 10 Mar 2014 13:54:30 -0500, Stacy wrote:

> Clay, thanks for taking the time to respond with your suggestions. > > This project is for my own curiosity so patent issues do not apply. > > To reiterate, at this stage I have either ‘spaces’ that have a value > close to zero or two sine waves (marks). The challenge right now is > finding where the ‘marks’ are. If I expand this project I know there > will a whole plethora of other issues to resolve. > > I) It has been suggested to use a sliding DFT. > Q1) Is that an actual plain vanilla DFT or an FFT? > Q2) If it is a DFT, can I assume it would mean making the calculation > using only the 8 DTMF tones? > > II) It has also been suggested to use an envelope detector. My search > entering the phrase “envelope detector” has not been too fruitful since > I wish to implement this in s/w. I seem to be getting the notion from my > search that using the Hilbert Transform for an envelope detector is the > way to go. I’m also still trying to find a s/w algorithm to do the > Hilbert Transform. > > III) Of course there is the old fashion way. Just use brute force and > count the samples that exceed an absolute value threshold and there is > the location of a ‘mark’. Knowing that, Goertzel works fine. > > But honestly, I would prefer to achieve desired results with a more > elegant solution such as (I) or (II), rather than what amounts to > counting on my fingers and toes. >
I don't know what's "elegant" to you vs. "counting on your fingers and toes", but I'd be mightily tempted to use the sliding DFT. If you use a DFT, and if you filter on both the inphase and quadrature signals in that DFT, then you'll get a pair of filter outputs for each frequency. The sum of the squares of these pairs will be pretty close to the square of the "envelope" of the output, with no explicit Hilbert transform required (the Hilbert transform is implicit in the inphase/ quadrature filtering). Depending on your processing power, using the suggested IIR bandpass filters may or may not take less processing power -- that would be "elegant" to me, but I don't know how you count such. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
>I don't know what's "elegant" to you vs. "counting on your fingers and >toes", but I'd be mightily tempted to use the sliding DFT. >
1) How long should the DFT be? 2) When using the sliding DFT how many samples do you increment each window? _____________________________ Posted through www.DSPRelated.com
On Tue, 11 Mar 2014 22:21:26 -0500, "Stacy" <22429@dsprelated> wrote:

>>I don't know what's "elegant" to you vs. "counting on your fingers and >>toes", but I'd be mightily tempted to use the sliding DFT. >> > >1) How long should the DFT be?
You'll need to answer that one yourself considering how much latency you can tolerate, any buffering limitations, how much processing gain you need or want for the tone detection, your sample rate and the desired frequency resolution.
> >2) When using the sliding DFT how many samples do you increment each >window?
The basic sliding DFT works one sample at a time. There are tricks to slide it further than that, but the basic algorithm provides one new output sample per DFT bin with every new input sample.
> >_____________________________ >Posted through www.DSPRelated.com
Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
>Eric Jacobsen >Anchor Hill Communications >http://www.anchorhill.com
Eric, Look what I found. http://homepages.cae.wisc.edu/~ece734/references/lyons.pdf http://www.cmlab.csie.ntu.edu.tw/DSPCourse/reference/Sliding%20DFT%20update.pdf _____________________________ Posted through www.DSPRelated.com
On Wed, 12 Mar 2014 05:18:14 +0000, Eric Jacobsen wrote:

> On Tue, 11 Mar 2014 22:21:26 -0500, "Stacy" <22429@dsprelated> wrote: > >>>I don't know what's "elegant" to you vs. "counting on your fingers and >>>toes", but I'd be mightily tempted to use the sliding DFT. >>> >>> >>1) How long should the DFT be? > > You'll need to answer that one yourself considering how much latency you > can tolerate, any buffering limitations, how much processing gain you > need or want for the tone detection, your sample rate and the desired > frequency resolution. >
Your needed processing gain depends, in turn, on the reliability you want vs. the signal to noise ratio -- more and higher resistance to erroneous detection noise means a longer filter, and visa versa.
> >>2) When using the sliding DFT how many samples do you increment each >>window? > > The basic sliding DFT works one sample at a time. There are tricks to > slide it further than that, but the basic algorithm provides one new > output sample per DFT bin with every new input sample.
Note that the sliding DFT is a kind of bandpass filter. There's a lot of different bandpass filters that could be used -- the sliding DFT is just the one that many non signal-processing types find to be the most intuitive, or at least the easiest to accept. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On Wed, 12 Mar 2014 00:28:55 -0500, "Stacy" <22429@dsprelated> wrote:

>>Eric Jacobsen >>Anchor Hill Communications >>http://www.anchorhill.com > > >Eric, > >Look what I found. > >http://homepages.cae.wisc.edu/~ece734/references/lyons.pdf > >http://www.cmlab.csie.ntu.edu.tw/DSPCourse/reference/Sliding%20DFT%20update.pdf
I hope you find it useful! ;) Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
On Wed, 12 Mar 2014 16:35:38 -0500, Tim Wescott
<tim@seemywebsite.really> wrote:

>On Wed, 12 Mar 2014 05:18:14 +0000, Eric Jacobsen wrote: > >> On Tue, 11 Mar 2014 22:21:26 -0500, "Stacy" <22429@dsprelated> wrote: >> >>>>I don't know what's "elegant" to you vs. "counting on your fingers and >>>>toes", but I'd be mightily tempted to use the sliding DFT. >>>> >>>> >>>1) How long should the DFT be? >> >> You'll need to answer that one yourself considering how much latency you >> can tolerate, any buffering limitations, how much processing gain you >> need or want for the tone detection, your sample rate and the desired >> frequency resolution. >> > >Your needed processing gain depends, in turn, on the reliability you want >vs. the signal to noise ratio -- more and higher resistance to erroneous >detection noise means a longer filter, and visa versa. > >> >>>2) When using the sliding DFT how many samples do you increment each >>>window? >> >> The basic sliding DFT works one sample at a time. There are tricks to >> slide it further than that, but the basic algorithm provides one new >> output sample per DFT bin with every new input sample. > >Note that the sliding DFT is a kind of bandpass filter. There's a lot of >different bandpass filters that could be used -- the sliding DFT is just >the one that many non signal-processing types find to be the most >intuitive, or at least the easiest to accept.
Well, I've found that there are many signal-processing types that seem to have a hard time with the sliding DFT for whatever reason, too. ;)
>-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com >
Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
On 3/12/14 6:21 PM, Eric Jacobsen wrote:
> On Wed, 12 Mar 2014 16:35:38 -0500, Tim Wescott > <tim@seemywebsite.really> wrote: >
...
>> >> Note that the sliding DFT is a kind of bandpass filter. There's a lot of >> different bandpass filters that could be used -- the sliding DFT is just >> the one that many non signal-processing types find to be the most >> intuitive, or at least the easiest to accept. > > Well, I've found that there are many signal-processing types that seem > to have a hard time with the sliding DFT for whatever reason, too. > ;) >
i don't have a problem with sliding DFT. and a sliding DFT for a small subset of DFT bins is best done using Goertzel. but i think that neither DFT nor Goertzel are the only nor the optimal nor the simplest way to approach this DTMF thing. if you want to be optimal, think of each of 16 pairs of filters as matched filters tuned to each DTMF tone pair. back in the olden daze, the way we were taught to approach a problem of signal detection by matching a filter to that signal we are trying to detect. this is sorta like M-ary communication except it's a constellation of frequency pairs instead of something on the I and Q axes. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Wed, 12 Mar 2014 19:03:21 -0400, robert bristow-johnson wrote:

> On 3/12/14 6:21 PM, Eric Jacobsen wrote: >> On Wed, 12 Mar 2014 16:35:38 -0500, Tim Wescott >> <tim@seemywebsite.really> wrote: >> > ... >>> >>> Note that the sliding DFT is a kind of bandpass filter. There's a lot >>> of different bandpass filters that could be used -- the sliding DFT is >>> just the one that many non signal-processing types find to be the most >>> intuitive, or at least the easiest to accept. >> >> Well, I've found that there are many signal-processing types that seem >> to have a hard time with the sliding DFT for whatever reason, too. >> ;) >> >> > i don't have a problem with sliding DFT. and a sliding DFT for a small > subset of DFT bins is best done using Goertzel. > > but i think that neither DFT nor Goertzel are the only nor the optimal > nor the simplest way to approach this DTMF thing. > > if you want to be optimal, think of each of 16 pairs of filters as > matched filters tuned to each DTMF tone pair. back in the olden daze, > the way we were taught to approach a problem of signal detection by > matching a filter to that signal we are trying to detect. this is sorta > like M-ary communication except it's a constellation of frequency pairs > instead of something on the I and Q axes.
Mary doesn't have to mind her I's and Q's; she can be a frequent flyer. I'd say that it _is_ M-ary communication, in an oddball sort of way. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com