B4A Library DTMF Decoder Library

Hi everyone,
This is my first library.
This library decodes codes which are sent by us to IVR during call (Like Press 1 to know your balance Press 2 to recharge ....).
This library can only be used in Activity no services are allowed.

Functions,Objects and Events :

Initialize()
It starts the decoder.

register()
It registers the decoder to listen.It is compulsory to keep it after initialization as if after initializing it any DTMF tone is detect an event call will be processed.

clearText()
As it name denotes it clears text stored in fullText.

maddtmf_keypress(key As Char)
Root of my library.It is called on every key press but if your activity is paused then it is not called.

fullText as string
This string contains all the key press.


Example:
B4X:
Sub Globals
   Dim d As madDTMF

End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.Initialize("main")
Activity.LoadLayout("main")

'This DTMF Decoder will work till this Application is running
'It initializes the reciever
d.Initialize()
'but even after initializing you have to register it.
d.register()
End Sub

'This event is not called when activity is paused.
Sub maddtmf_keypress(key As Char)
'You can check d.fullText variable in regular interval of time to know every key press.
'we are using here to update textbox on next visible keystroke
Keys.Text=d.fullText
'Key contains new key press.
Log(key)
End Sub

Update :
Library works over call on Gingerbread 2.3.3 on Samsung Galaxy Y.
But application Does on support Samsung Galaxy S4(i9500) . May be ICS does not support the same over call.
 

Attachments

  • madDTMFDecoder_lib.zip
    24.5 KB · Views: 749
  • madDTMFDecoder_Sample.zip
    7.2 KB · Views: 673
Last edited:

alexhi

Member
Licensed User
Longtime User
Hello! It can take the DTMF signal from the microphone?

Hello! It can take the DTMF signal from the microphone?
 

madSac

Active Member
Licensed User
Longtime User
Currently i have not added microphone support. But in future i will add.
 

dmtulsa

Member
Licensed User
Longtime User
It would be great if you could enter a tone pair instead of a 0-9. There are many uses for DTMF other than Phone tones. The frequency pairs are close but not the same as standard tones. This would be very useful. Also controlling the tone pair amplitudes is very useful.

Thank
Doug
 

ggutier

New Member
Licensed User
Longtime User
Dtmf

Hello

Could you please tell me how to use it? Because after the call is stablished I invoke your program and no tones are detected.

Thank
 

dmtulsa

Member
Licensed User
Longtime User
How is the lib coming along? I could really use something like this. We test a lot of microphones with DTMF keypads and we have to test each key. Now I use a dedicated DTMF decoder chip and a LED matrix but it would nice to use a tablet. I assume I could use the mic input part of the head phone jack. Any thoughts??

Thanks
Doug
 

madSac

Active Member
Licensed User
Longtime User
I have tried the DTMF decoder and have the same problem: it doesn't work. Any solutions? Have you made the microphone version yet?
I have to rework on library. as i was off from computer.
I will post update ASAP.
 

madSac

Active Member
Licensed User
Longtime User
After trying to compile library on my Samsung Galaxy S4. i found that the application crashed.
I tried other applications also but all of them crashed. Probably ICS does not support DTMF decoding over call.

I will provide an option to change sound source. Probably that will be better option.
 

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello @madSac : please, have you already had a chance to rework on your library, yet ?
 

Sgardy

Member
Licensed User
Longtime User
Hello! Do it's possible to detect single tone? By example if tone is 2KHz do something? Thank you!
 

peacemaker

Expert
Licensed User
Longtime User
Any update ? At least ot make the object not Activity object to work in a service...
 

danoveb

Member
Licensed User
Longtime User
Android 6.0.1:

LogCat connected to: B4A-Bridge: Sony D6503
--------- beginning of main
** Activity (main) Create, isFirst = false **
running waiting messages (1)
** Activity (main) Resume **
** Service (service1) Destroy **
** Service (service1) Create **
** Service (service1) Start **
Connected to B4A-Bridge (Wifi)
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:madsacsoft.maddev.dtmf
** Activity (main) Create, isFirst = true **
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalArgumentException: Invalid audio source.
at android.media.AudioRecord.audioParamCheck(AudioRecord.java:625)
at android.media.AudioRecord.<init>(AudioRecord.java:358)
at android.media.AudioRecord.<init>(AudioRecord.java:271)
at dtmf.RecordTask.doInBackground(RecordTask.java:31)
at dtmf.RecordTask.doInBackground(RecordTask.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 4 more
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
 
Top