I made a small device (I know electronics also) that takes the sound from the phone line into my computer, into line input.
I want to make a program that recognizes the number you press on the phone by analizing the sound from it. We all know that each button makes a different sound, but the problem is recognizing witch one is what.
Any help ?
Last edited by CVMichael; Feb 26th, 2005 at 12:54 AM.
You can get the frequencies from the Internet, but the problem is that each buton is actually two frequencies at once. Not sure how you would be able to detect which TWO you were picking up at the same time. I think you'd need some hardware to do it right. Some modem's had something like this, that controlled access to the voice recorder that was onboard.
The device I made is simply aplifying the sound from the phone line for the input in the sound card. Next step is to make software recognize the numbers you press on the phone.
I attached a picture of a test i did.
In a sound editor program I generated a 1209 Hz sound, and a 697 Hz sound, then i mixed the 2 sounds.
The last wave (on the bottom) is the actual sound recorded from the phone when pressing number 1.
The sounds a re very close to the digital one, now i have to figure out a way to compare them. Also i have to figure out a way to sincronize the sounds, so that the recorded one has the same position as the reproduced digital one.
they still appear different. you should generate numbers for each wave. keep me posted on your progress. it seems that you know what you are doing. let me know if there is anything i can do to help.
Why not generate a value for each of the combined frequencies (#'s 0 -9).
(My guess here is that the two combined should be one specific value on a sine wave.)
THen when you get the sound, convert it to a number and compare this against your table of numbers 0-9.
Actually if you look at the third sound and forth sound in the attached picture, they are almost identical.
Originally Posted by dw85745
Why not generate a value for each of the combined frequencies (#'s 0 -9).
(My guess here is that the two combined should be one specific value on a sine wave.)
If it was THAT easy, I would have finished by now.
Originally Posted by dw85745
If your trying to make a phone dialer to beat the phone company there are many magazines that address this issue but MUCH prison time attached.
I don't quite get what your saying. There is a phone dialer program that comes with windows, i'm not making a phone dialer. I'm not trying to beat any company. And recording the phone numbers you dial out from your home is perfectly legal, i'm not trying to record phone call numbers on someone else's line, it's my line, at my home, witch is perfectly legal.
it won't be easy to do. if you can't turn on the reording when the phone is off-hook, then you will have a lot of dead space. but that is a different problem altogether. and the bottom one is not as loud as the one above it, so they will never be the same.
The automatic recording I’ve already done, it turns on when it's sound, and turns off after 10 seconds of silence, completely automatic. It converts to MP3 also
About this: "and the bottom one is not as loud as the one above it, so they will never be the same."
That's just matter of equalizing the sound, I have to find the peek value, then amplify the buffer to max, so the largest "bump"/sound in the wave buffer will be at 100%
Even after that will never be identical, and that's why i can't just convert the buffer into one number. I have to compare the buffer with the digital one, and get match percentage.
If i get like over 95% simmilarity then it's that number, otherwise compare with the next digital buffer (next number), and so on, until you get the match, or not (it could be someone's voice).
I thought that someone already have done this, and could explain me what to do to make my work easyer, but aparently no one has a clue on how to make this work.
Also, to make the comparison faster i will probably have to convert the sound to 8 bit (or even lower), and sampling rate anywehere between 4000 Hz to 8000 Hz
I was wrong in the previus post, making the sampling rate of 4000 Hz it make the wave data almost unreadable, I tested and the best frequency is 16000.
I just wrote this code.
To whomever is interested, this code generates wave files for the tones for all the buttons, + dial tone, ring back, and busy signal.
With this code you can create sound files with sampling rate up to 96000 Hz. (Actually any sampling rate, as long as your sound card can take it...)
VB Code:
Option Explicit
Private Type tWAVEFORMATEX
wFormatTag As Integer
nChannels As Integer
nSamplesPerSec As Long
nAvgBytesPerSec As Long
nBlockAlign As Integer
wBitsPerSample As Integer
cbSize As Integer
ExtraData(1 To 32) As Byte ' makes the structure 50 bytes long
End Type
Private Type FileHeader
lRiff As Long
lFileSize As Long
lWave As Long
lFormat As Long
lFormatLength As Long
End Type
Private Type WaveFormat
wFormatTag As Integer
nChannels As Integer
nSamplesPerSec As Long
nAvgBytesPerSec As Long
nBlockAlign As Integer
wBitsPerSample As Integer
End Type
Private Type ChunkHeader
lType As Long
lLen As Long
End Type
Private Const PI As Double = 3.14159265358979 ' 4 * Atn(1)
[edit]
Ow my god, I found this thread on the first page in google, it's only the 6'th link from the top cooolll, hehe
I can't believe it's on a major search engine so fast...
That is a pretty interesting clip. I can't believe it is running on a PC! It seems pretty quick! Man, things have certainly changed in the past 10 years.
I could think of some really wicked uses for some code like that.
Keep up the good work.
Just as I was saying I had to compare the sound from the phone with the sound digitally generated and get a percentage out of it.
For every buffer it compared with ALL numbers, it compared with #1, #2... etc, and displays the percentage for all, then it's just a matter of getting the highest percentage, and there you go, you have the lucky number (the one you press on the phone)
Here's an example:
All I did was to pick up the phone (you get a dial tone), and pressed 1 then 2 then 3.
This is the result I got:
Right now I did not make it recognize the dial tone or other phone sounds, it's only the numbers.
The percentage is not very high, but you can definitelly tell the difference, and well... it's a start...
Right now it's converting the bits from 16 bits to 5 bits, and with a frequency of 32000 Hz, but I have to play with those number more.
I think I will be able to bring the percentage up to 80-90 percent, and a bigger difference between the numbers it recognizes to the number that it does not recognize.
Last edited by CVMichael; Feb 22nd, 2005 at 08:21 PM.
The way that this problem is normally handled is by running your waveform through a fast Fourier transform (FFT) which will recover the two original frequencies. Once you know those, you know what buttons have been pushed.
If interested here is one of many sites http://www.fftw.org/links.html
I think my buddy was using that 20+ years ago. He had a program that would plot data from an oscilliscope, through a serial port. I know he was proud of its speed. Very fast.
Right now i'm trying to convert the VB code into C++ DLL code, I want to write the functions that do a lot of loops into C++ because right now in VB it takes 100% of the CPU, and it needs even more CPU (with a P4 1.4GHz).
I converted the simplest functions, only about 20 lines of code, but for some reason the C++ code makes my program crash, but at least it takes only 30% to 50% of the CPU....
I'm using double arrays to store the digitaly generated tones, something like Tones(10, 3000) As Integer, I pass to the C++ code the array, but only one dimension at one time, like:
MyAPIFunction VarPtr(Tones(1, 0)), UBound(Tones, 2), 'and the other params
And for some reason the C++ code gets different data...
' ReDimming the array to the right size depending on the how many samples / sec
K = LeftSrcFMT.nSamplesPerSec * 0.03
ReDim ToneNumber(10, K)
' Declaration
Public Declare Function GetMatch Lib "Functions.dll" (ByVal BigBuff As Long, ByVal Pos As Long, ByVal SmallBuff As Long, ByVal SmallBuffSize As Long, ByVal Step As Integer) As Double
' Calling the function
' SmallBuffer is actually ToneNumber (get's renamed because this line is in a function I call from somewhere else)
_declspec(dllexport) double _stdcall GetMatch(short *BigBuff, long pos, short *SmallBuff, long SmallBuffSize, short Step)
So... this is one of the functions that I have problems with...
When I call it, I get different data in the C++ funcion than it's equivalent VB function
I converted the VB code to C++, and from the C++ code I different results than VB's code
And also, the C++ code, sometimes (if called many times) it's crashing my program
Last edited by CVMichael; Feb 25th, 2005 at 09:00 PM.
I finished... I converted the main functions to C++, now it takes less than 10 milliseconds !! to analize a 100 millisecond buffer with ALL numbers.
So, basically, it takes 100 ms to record and another 10 ms to tell me what number I pressed , pretty cool eh ? so from the time I press the number on the phone it takes 110 milliseconds to display on the screen what number i pressed.
It is very accurate also, all the tries I made, it never made a mistake, the percentage is still pretty low, between 20 and 40 percent, and when it does not recognize a number it's about 3-8 percent, so it's still a pretty big difference, and also, when it does not recognize a number the percentage is about 3-8 percent for all the numbers, when it does recognize a number, the percentage is high only for the number I press. So basically, I can make an average of all the percentages, and I know when I press a number, or when it's any other sound...
Also, the buffer is "maximized" all the time, it takes the peek value, and amplifies the sound to 100 percent, so it does not matter what is the volume of the sound, as long as it's not too low or too loud (distorted).
OMG !!!
I did not even connect my device to the computer, I turned on the computer's microphone, I put the phone's handset near the microphone and it recognized the butons !!! this thing is better than i thought, the percentage was very low, like 7%, compared to unrecognized 3-5 %, it also made about 15 % mistakes, but it was through the microphone !! cool...
Ready to go ? ... amm... so ... so... code is a bit messy, have to make it recognize dial tone, busy signal, etc... but those sounds are almost the same as the buttons, so it won't be a big deal.
I want to make optimizations, but for what I need right now, it's working fine, maybe for different kind of sounds.
Also, i know you are eager to view my code, but i was thinking about that all this time, and I'm not sure I want to give it away just like that... though it is so simple, i mean the main functions (2 functions) together are about 30 lines of code, and the rest is just sound recording stuff... and creating the digital sounds to compare to is about 10 lines of code... it is very simple, I don't understand why there are not many people who made programs like this...
But i don't what to give it away, because i'm thinking maybe I can profit from it, maybe I can make a program and sell it... even though I tried that in the past and never sold anything.... (had nothing to do with sound)
And also, I hate when people that have no idea about programming, get my program make some small changes (maybe add a nice interface) and say they made it, and profit from it.
Even though the code is simple and small, it took me quite a while to do, and i would hate if my time would go to waste...
Anyways, if you want to check out a compiled program, I'll put it here, but i'm SURE no one would actually run it... ( I would not download other people's exes )
Congratulations on getting your program to work so well.
I don't understand why there are not many people who made programs like this...
There are, like I mentioned before this is a very common task in the world of research and development. Most people don't mess with software versions anymore since there are many chips that do the same thing but much faster, check out a Radio Shack catalog. The approach you took was uncommon however because it is more efficient to use fast Fourier transforms to do the same thing.
As far as a product goes, I wonder what someone would want a software tone decoder for? Now if you could make a better voice recognition system I think you'd be making some big bucks.
OK, I'll take the C++ functions from my DLL (I also have functions not related with this in my DLL), when I have time, tomorow maybe.
To take the tones, you don't need to, just use my digitally created ones...
If you want to take the sound (in general), then you need a device, you will find a phone recording device from Radio Shack (or your equivalent store, depending where you live, if you have those around)
If you want, I can give you my schematics (wich I invented ), that works better than what you buy. The recording device I got from Radio Shack did not work for the lines I was using, It made a ~60 Hz sound when pluged in the computer, the filter they use is useless...
I don't know how to take the sound through the modem, that was my "next to do" on my list, but I never got to it yet
I am going to think about uses for it for a while. Take your time with the .dll's.
I am thinking of a couple uses, and I'll let you know when I have figured out if they will work or not.
I posted another project that is using a C++ DLL, it's much faster now, check the "VB - Tone Recognition" thread.
I also attached a schematic of my device that takes the sound from the phone line to the coputer microphone, or auxiliary input in the computer (but that needs an adapter to power it up)
I really doubt that many will understand the schematic (I wander how many people on this forums knows electonics also)
PS, all the components in the device are components from broken phones (components that work... from broken phones)
My knowledge of electronics doesn't include reading ciruits, but I can get the gist of what you are doing. I know many different aspects of electronic specialties, but have never built a PC board, or actually any circuits in the past 30 years. I had a Radio Shack kit as a kid, but that's about it.
Actually I could think of one commercial use for an application like this. At least if you build on it a bit more so that after you've dialed your number check for a reply and then time how long the phone call is. That would be something I would use to be able to check if my phone bill actually is correct. So if you would make that I'll pay you for using a copy of it