Page 1 of 2 12 LastLast
Results 1 to 40 of 45

Thread: Sound Recognition [ Solved ]

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Resolved Sound Recognition [ Solved ]

    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.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition

    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.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    I found this on the web: http://www.elexp.com/t_tele.htm

    It seems that all numbers is a combination of 2 frequencies:


    How would I go about recognizing the combinations ?

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition

    You said that you knew electronics, wouldn't you need hardware to do it?
    Some kind of D/A converter, I'd imagine.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    I want to do it through software not hardware...

    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.
    Attached Images Attached Images  

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition

    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.

  7. #7
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Sound Recognition

    Interesting Problem:

    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.

    -------------------------------------------------------------

    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.
    Last edited by dw85745; Feb 20th, 2005 at 09:44 AM.

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    Quote Originally Posted by dglienna
    they still appear different. ...
    Actually if you look at the third sound and forth sound in the attached picture, they are almost identical.

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

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

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition

    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.

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    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.

    I guess i'll be on my own.

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    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

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    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:
    1. Option Explicit
    2.  
    3. Private Type tWAVEFORMATEX
    4.     wFormatTag As Integer
    5.     nChannels As Integer
    6.     nSamplesPerSec As Long
    7.     nAvgBytesPerSec As Long
    8.     nBlockAlign As Integer
    9.     wBitsPerSample As Integer
    10.     cbSize As Integer
    11.     ExtraData(1 To 32) As Byte ' makes the structure 50 bytes long
    12. End Type
    13.  
    14. Private Type FileHeader
    15.     lRiff As Long
    16.     lFileSize As Long
    17.     lWave As Long
    18.     lFormat As Long
    19.     lFormatLength As Long
    20. End Type
    21.  
    22. Private Type WaveFormat
    23.     wFormatTag As Integer
    24.     nChannels As Integer
    25.     nSamplesPerSec As Long
    26.     nAvgBytesPerSec As Long
    27.     nBlockAlign As Integer
    28.     wBitsPerSample As Integer
    29. End Type
    30.  
    31. Private Type ChunkHeader
    32.     lType As Long
    33.     lLen As Long
    34. End Type
    35.  
    36. Private Const PI As Double = 3.14159265358979 ' 4 * Atn(1)
    37.  
    38. Private Sub Form_Load()
    39.     GenerateTone App.Path & "\Number 1.wav", 697, 1209
    40.     GenerateTone App.Path & "\Number 2.wav", 697, 1336
    41.     GenerateTone App.Path & "\Number 3.wav", 697, 1477
    42.    
    43.     GenerateTone App.Path & "\Number 4.wav", 770, 1209
    44.     GenerateTone App.Path & "\Number 5.wav", 770, 1336
    45.     GenerateTone App.Path & "\Number 6.wav", 770, 1477
    46.    
    47.     GenerateTone App.Path & "\Number 7.wav", 852, 1209
    48.     GenerateTone App.Path & "\Number 8.wav", 852, 1336
    49.     GenerateTone App.Path & "\Number 9.wav", 852, 1477
    50.    
    51.     GenerateTone App.Path & "\Number Star.wav", 941, 1209
    52.     GenerateTone App.Path & "\Number 0.wav", 941, 1336
    53.     GenerateTone App.Path & "\Number #.wav", 941, 1477
    54.    
    55.     GenerateTone App.Path & "\Dial Tone.wav", 350, 440, , , 2
    56.     GenerateTone App.Path & "\Ring Back.wav", 440, 480, , , 2
    57.     GenerateTone App.Path & "\Busy.wav", 480, 620, , , 2
    58. End Sub
    59.  
    60. Private Sub GenerateTone(ByVal FileName As String, ByVal HFrequency As Long, ByVal VFrequency As Long, _
    61.         Optional ByVal BitsPerSample As Integer = 16, Optional ByVal SamplesPerSec As Long = 44100, Optional ByVal SecondsLength As Single = 1)
    62.     Dim WF As tWAVEFORMATEX
    63.     Dim Buff() As Byte, IntBuff() As Integer, K As Long, V1 As Double, H1 As Double
    64.    
    65.     WF.wFormatTag = 1 'WAVE_FORMAT_PCM
    66.     WF.nChannels = 1
    67.     WF.wBitsPerSample = BitsPerSample
    68.     WF.nSamplesPerSec = SamplesPerSec
    69.    
    70.     WF.nBlockAlign = (WF.wBitsPerSample * WF.nChannels) \ 8
    71.     WF.nAvgBytesPerSec = WF.nSamplesPerSec * WF.nBlockAlign
    72.    
    73.     V1 = WF.nSamplesPerSec / (PI * 2 * VFrequency)
    74.     H1 = WF.nSamplesPerSec / (PI * 2 * HFrequency)
    75.    
    76.     If WF.wBitsPerSample = 8 Then
    77.         ReDim Buff(WF.nSamplesPerSec * SecondsLength - 1)
    78.        
    79.         For K = 0 To UBound(Buff)
    80.             Buff(K) = 128 + Fix(Sin(K / V1) * 63.5 + Sin(K / H1) * 63.5)
    81.         Next K
    82.     Else
    83.         ReDim IntBuff(WF.nSamplesPerSec * SecondsLength - 1)
    84.        
    85.         For K = 0 To UBound(IntBuff)
    86.             IntBuff(K) = Fix(Sin(K / V1) * 16383.5 + Sin(K / H1) * 16383.5)
    87.         Next K
    88.     End If
    89.    
    90.     Open FileName For Binary Access Write As #1
    91.     WaveWriteHeader 1, WF
    92.    
    93.     If WF.wBitsPerSample = 8 Then
    94.         Put #1, , Buff
    95.     Else
    96.         Put #1, , IntBuff
    97.     End If
    98.    
    99.     WaveWriteHeaderEnd 1
    100.     Close #1
    101. End Sub
    102.  
    103. Private Sub WaveWriteHeader(ByVal OutFileNum As Integer, WaveFmt As tWAVEFORMATEX)
    104.     Dim header As FileHeader
    105.     Dim HdrFormat As WaveFormat
    106.     Dim chunk As ChunkHeader
    107.    
    108.     With header
    109.         .lRiff = &H46464952 ' "RIFF"
    110.         .lFileSize = 0
    111.         .lWave = &H45564157 ' "WAVE"
    112.         .lFormat = &H20746D66 ' "fmt "
    113.         .lFormatLength = Len(HdrFormat)
    114.     End With
    115.    
    116.     With HdrFormat
    117.         .wFormatTag = WaveFmt.wFormatTag
    118.         .nChannels = WaveFmt.nChannels
    119.         .nSamplesPerSec = WaveFmt.nSamplesPerSec
    120.         .nAvgBytesPerSec = WaveFmt.nAvgBytesPerSec
    121.         .nBlockAlign = WaveFmt.nBlockAlign
    122.         .wBitsPerSample = WaveFmt.wBitsPerSample
    123.     End With
    124.    
    125.     chunk.lType = &H61746164 ' "data"
    126.     chunk.lLen = 0
    127.    
    128.     Put #OutFileNum, 1, header
    129.     Put #OutFileNum, , HdrFormat
    130.     Put #OutFileNum, , chunk
    131. End Sub
    132.  
    133. Private Sub WaveWriteHeaderEnd(ByVal OutFileNum As Integer)
    134.     Dim header As FileHeader
    135.     Dim HdrFormat As WaveFormat
    136.     Dim chunk As ChunkHeader
    137.     Dim Lng As Long
    138.    
    139.     Lng = LOF(OutFileNum)
    140.     Put #OutFileNum, 5, Lng
    141.    
    142.     Lng = LOF(OutFileNum) - (Len(header) + Len(HdrFormat) + Len(chunk))
    143.     Put #OutFileNum, Len(header) + Len(HdrFormat) + 5, Lng
    144. End Sub

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition

    I'm going to have to try that. That is really sweet. I like that.
    Keep me posted on the progress. It looks like it may really be possible to do!
    Last edited by dglienna; Feb 21st, 2005 at 12:31 AM.

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    I'M SURE OF IT !!! i just need enough time... (have a full time job)

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    Check out the movie in this link I found searching on google, it's really cool
    http://www.merl.com/projects/SoundRecognition/

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

  16. #16
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition

    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.

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    I DID IT !!!! IT WORKS !!! YEEEYYY

    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:
    VB Code:
    1. 1: 13.542  2: 12.813  3: 12.917  4: 14.271  5: 12.813  6: 12.917  7: 12.917  8: 13.229  9: 13.021  0: 13.438    <= Dial tone
    2. 1: 11.979  2: 11.771  3: 11.354  4: 13.125  5: 11.771  6: 11.771  7: 11.979  8: 11.667  9: 11.875  0: 12.500    <= Dial tone
    3. 1: 05.208  2: 05.521  3: 05.417  4: 05.729  5: 04.896  6: 04.792  7: 04.583  8: 04.688  9: 04.896  0: 06.563    <= Dial tone
    4. 1: 04.583  2: 05.000  3: 03.438  4: 05.000  5: 04.583  6: 04.896  7: 05.000  8: 05.000  9: 04.583  0: 06.146    <= Dial tone
    5. 1: 03.854  2: 04.792  3: 03.229  4: 05.208  5: 04.792  6: 05.000  7: 04.479  8: 04.583  9: 04.792  0: 05.833    <= Dial tone
    6. 1: 04.375  2: 04.792  3: 03.229  4: 05.208  5: 05.000  6: 04.896  7: 04.792  8: 04.375  9: 04.583  0: 05.729    <= Dial tone
    7. 1: 04.479  2: 05.313  3: 03.229  4: 05.417  5: 04.583  6: 04.792  7: 05.104  8: 04.479  9: 04.896  0: 05.313    <= Dial tone
    8. 1: [COLOR=Red]14.479[/COLOR]  2: 09.583  3: 08.125  4: 09.063  5: 08.333  6: 08.125  7: 08.854  8: 08.125  9: 08.125  0: 08.438    <= Number 1
    9. 1: [COLOR=Red]26.354[/COLOR]  2: 07.917  3: 06.146  4: 08.229  5: 05.521  6: 05.833  7: 07.813  8: 06.563  9: 05.938  0: 05.729    <= Number 1
    10. 1: [COLOR=Red]22.708[/COLOR]  2: 10.208  3: 11.458  4: 11.042  5: 10.313  6: 10.208  7: 10.729  8: 11.146  9: 09.688  0: 10.208    <= Number 1
    11. 1: 10.521  2: 11.146  3: 10.104  4: 10.313  5: 10.208  6: 10.208  7: 10.000  8: 10.000  9: 10.000  0: 10.625    <= pause (no sound)
    12. 1: 00.000  2: 00.000  3: 00.000  4: 00.000  5: 00.000  6: 00.000  7: 00.000  8: 00.000  9: 00.000  0: 00.000    <= pause (no sound)
    13. 1: 07.292  2: [COLOR=Red]24.271[/COLOR]  3: 07.708  4: 06.667  5: 08.021  6: 06.979  7: 05.729  8: 07.083  9: 07.188  0: 08.125    <= Number 2
    14. 1: 07.500  2: [COLOR=Red]22.604[/COLOR]  3: 07.188  4: 06.875  5: 08.021  6: 07.604  7: 06.146  8: 07.292  9: 07.188  0: 07.292    <= Number 2
    15. 1: 08.333  2: [COLOR=Red]19.375[/COLOR]  3: 06.875  4: 07.708  5: 07.917  6: 07.083  7: 06.563  8: 07.813  9: 07.188  0: 07.188    <= Number 2 / no sound
    16. 1: 10.833  2: 11.042  3: [COLOR=Red]15.104[/COLOR]  4: 10.833  5: 11.250  6: 10.625  7: 10.938  8: 10.938  9: 11.042  0: 10.729    <= no sound / Number 3
    17. 1: 11.250  2: 10.625  3: [COLOR=Red]26.146[/COLOR]  4: 11.354  5: 10.833  6: 11.146  7: 11.042  8: 11.563  9: 11.771  0: 11.250    <= Number 3
    18. 1: 06.979  2: 07.500  3: [COLOR=Red]25.729[/COLOR]  4: 05.521  5: 06.875  6: 08.125  7: 05.521  8: 07.292  9: 07.917  0: 06.563    <= Number 3
    19. 1: 07.813  2: 07.917  3: [COLOR=Red]28.021[/COLOR]  4: 05.521  5: 06.979  6: 07.708  7: 05.313  8: 06.875  9: 08.229  0: 07.500    <= Number 3
    20. 1: 08.958  2: 09.479  3: 09.063  4: 10.000  5: 09.583  6: 08.646  7: 08.958  8: 09.479  9: 08.646  0: 09.375    <= no sound
    21. 1: 13.125  2: 12.708  3: 11.667  4: 12.917  5: 12.083  6: 11.667  7: 12.292  8: 11.563  9: 11.875  0: 12.396    <= no sound
    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.

  18. #18
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Thumbs up Re: Sound Recognition

    Quote Originally Posted by CVMichael
    I found this on the web: http://www.elexp.com/t_tele.htm

    It seems that all numbers is a combination of 2 frequencies:
    Yes. That is why it is called DTMF (Dual Tone Multi Frequency).


    Excellent job on the recognition code!

  19. #19
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition

    I hope that you are going to share the code when you finish it. I'll find uses for it, that i'll share.

  20. #20
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Sound Recognition

    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

  21. #21
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition

    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.

  22. #22

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    FYI, I'm still working on this thing.

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

    Anyways.... I'll figure it out...

  23. #23
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Sound Recognition

    How are the functions declared in C++ and in VB?
    Try reversing the row and columns in the C++ routine.

  24. #24

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    OK, here's one of them...

    VB Code:
    1. ' Array declared public in a module
    2. Public ToneNumber() As Integer
    3.  
    4. ' ReDimming the array to the right size depending on the how many samples / sec
    5. K = LeftSrcFMT.nSamplesPerSec * 0.03
    6. ReDim ToneNumber(10, K)
    7.  
    8. ' Declaration
    9. 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
    10.  
    11. ' Calling the function
    12. ' SmallBuffer is actually ToneNumber (get's renamed because this line is in a function I call from somewhere else)
    13. Per = GetMatch(VarPtr(BigBuff(0)), K, VarPtr(SmallBuff(Index, 0)), UBound(SmallBuff, 2) + 1, 1)
    14.  
    15. ' and finally, the C++ declaration
    16. _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.

  25. #25
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Sound Recognition

    OK, here is how I've done it succesfully

    On the VB side of things
    VB Code:
    1. 'The 2-d buffer is
    2. Dim Buffer(0 To 7, 0 To BufferSize) As Integer
    3.  
    4. 'Declare the dll routine
    5. Private Declare Function FluxCounts Lib "MyDll.dll" (Buffer as Integer, ByVal BufferSize as Long) As Long
    6.  
    7. 'Call the routine
    8. Y = (FluxCounts(Buffer(0, 0), BufferSize)
    On the C++ side
    Code:
    //Declare function
    __declspec( dllexport ) long _stdcall FluxCounts (short Buffer[][8], long BufferSize)
    //
    You can see that the rows and columns are reversed.

  26. #26

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    In the C++ code there is not rowns and colums... I want to pass only ONE array of all 10 arrays...

    I want to pass one of the rows from VB to C++

    Right now i've tried something like this:
    VB Code:
    1. Public Type tTone
    2.     Arr() As Byte
    3. End Type
    4.  
    5. Public ToneNumber(10) As tTone
    6.  
    7.  
    8. ' When Calling the function
    9. Per = GetMatch(VarPtr(BigBuff(0)), K, VarPtr(ToneNumber(Index).Arr(0)), UBound(ToneNumber(Index).Arr) + 1, 1)
    And this still does not work...

  27. #27

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    Nevermind !!
    Lately I seem to make stupid mistakes, I gues i'm kinda tired because of trying things...

    VB Code:
    1. ' this is not supposed to be byte array
    2. Public Type tTone
    3.     Arr() As Byte
    4. End Type
    5.  
    6. ' it's supposed to be integer array
    7. Public Type tTone
    8.     Arr() As Integer
    9. End Type

    I got it to work, thanks !

  28. #28

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

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

  29. #29
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition

    Cool. Any optimization planned? Or is it ready to go?

  30. #30

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition

    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 )

  31. #31
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition [ Solved ]

    think about it. maybe i'll pm you in a day or two.

  32. #32
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Sound Recognition [ Solved ]

    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.

  33. #33

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition [ Solved ]

    I changed my mind...

    Here it is: http://www.vbforums.com/showthread.php?t=336074

  34. #34

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition [ Solved ]

    dglienna, you mean the C++ DLL's ??

  35. #35
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition [ Solved ]

    Yes, if they are so much faster. Also, what is the best way to capture tones on a phone? Thru the modem? Or a microphone recording a speakerphone?

  36. #36

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition [ Solved ]

    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

  37. #37
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition [ Solved ]

    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.

  38. #38

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Sound Recognition [ Solved ]

    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)
    Attached Images Attached Images  

  39. #39
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Sound Recognition [ Solved ]

    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.

    Thanks. I'll look at the .dll's.

  40. #40
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Sound Recognition [ Solved ]

    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

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width