Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hi Guys,
I'm looking to receive, and interpret DTMF. That's two simultaneous tone frequencies,
I'm not completely versed with software detecting the frequency of just one tone.

I think I'm somewhat arriving at a solution in my head without having hit the computer yet.
Having used the audio out, I'm sure that using audio in, you'll end up with a sample buffer at
known sample format, and am sure if I try, I'll get that far.

What then? Are there any canned solutions for looking at the wave form
to count peaks? DTMF produced by dedicated chips will be nice clean sine waves.
I have a scope, and will be able to see that much.
Cheers, Art.
 

firewood

macrumors G3
Jul 29, 2003
8,115
1,355
Silicon Valley
You can use either the Audio Queue API or the RemoteIO Audio Unit to stream buffers of audio samples into an iOS app (plenty of docs on the Apple dev site). The Goertzel algorithm is probably the most appropriate method to detect the presence of tone frequencies whose waveforms are mostly sinusoidal inside a buffer of samples. You can also check the ratios of the Goertzel filter outputs and the total energy in the buffer to determine if the S/N ratio is sufficient for DTMF detection.
 

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Thanks that looks like some good starting points.
I'm sure there will be ready samples out there to get audio samples in a buffer,
from there it does look like a much more relaxing task to produce audio, than to interpret some of it.
 

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Thanks, but it looks a bit much considering detecting DTMF is the end of the road for the App.
I don't have to personally know anything about the audio, only the iOS App does.
Did I mention I have a scope ? :D

If you want to just analyse waveforms then you could give Audacity a shot..It's free for OSX:
http://audacity.sourceforge.net
 

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Looks like you've put me well on the right track firewood & thanks.

I will have to find a software implementation, when it comes time, and it will.
I get to cheat out this time, and only need to look for pressure points (pulses).

There's no way I'm following the Wikipedia formula through to a software implementation! :D
 

firewood

macrumors G3
Jul 29, 2003
8,115
1,355
Silicon Valley
There is a ton of C source code for the Goertzel algorithm on the net if you search for it. It can be done in less than a dozen lines of code.
 

ChrisA

macrumors G5
Jan 5, 2006
12,650
1,796
Redondo Beach, California
Hi Guys,
I'm looking to receive, and interpret DTMF. That's two simultaneous tone frequencies,..

DTMF decoding is a very common problem and there are a few free libraries for doing that. Every telephony system has to do this. I would not try and re-invent this wheel. Google "dtmf decode library" and you get a few pages of hits. This one is not bad:
http://sourceforge.net/projects/dtmf/

The solution to apply a filter then compare the ratio of filtered to unfiltered power is good. I'm pretty sure this is how they do it with analog circuits too. But why bother with such details when there are very well tested and fee solutions
 

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
DTMF decoding is a very common problem and there are a few free libraries for doing that. Every telephony system has to do this. I would not try and re-invent this wheel. Google "dtmf decode library" and you get a few pages of hits. This one is not bad:
http://sourceforge.net/projects/dtmf/

The solution to apply a filter then compare the ratio of filtered to unfiltered power is good. I'm pretty sure this is how they do it with analog circuits too. But why bother with such details when there are very well tested and fee solutions

It's a problem I get to totally evade this time :)
I did decide to go the hardware route, figuring that would be as refined as it gets,
but the IC stays in the packet because then I realised that overall,
I was aiming to to both produce DTMF, and then decode it for nothing
which is quite silly.

IMG_1907_zps63567f26.jpg
 

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Silly in the intended application maybe, but another one came up for a keypad interface in the reverse direction.

I have an App on my iPhone 5 called Blue Box (not my App).
IMG_6609_zps9661b279.png


This one, despite the name leading me to believe it was a modern day "fone phreak wannabe",
appears to be a real multi frequency signal generator.
You'd have to use some long samples or awesome loops to cheat out on it.

Here is a hardware circuit receiving DTMF through a hi-fi stereo:
*** snip *** updated video below VVVV

Just a warning to watch clipping on your phone if you do anything with audio :D
My iPhone 5 has to be turned down about halfway before it either clips,
or the speaker can no longer reproduce DTMF for whatever reason.

When I use a scope on the mic preamp output with iPhone 5 generating the DTMF,
it appears as though I'm amplifying existing clipping because there is some noise
introduced on the DC component.

I'm supposed to write the keypad app for the electronics.
I know how to use the low level audio, but it might pay to record long samples at a level that can't peak.
Cheers, Art.
 
Last edited:

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
So I updated the YouTube link in the post above with a speed test once I
figured out how to synthesise DTMF tones with iOS AudioUnits.
I might make a DTMF App since most Apps just play recorded samples.

https://www.youtube.com/watch?v=fhqFfszJLU0

Definitely a form of communication there where the iOS device takes charge of comms and sends then waits for recieve, then checks checksums.
Given the iOS devices lack a useable serial port, I think this beats flashing the camera LED into a light sensor.

Note that the video demo is an audio coupling (speaker/microphone) with some background noise.
A direct connection should be able to do this silently and more reliably.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.