Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating Sound or Tones in Foxpro

Status
Not open for further replies.

Derm

Programmer
Apr 10, 2001
9
CA
Is there a way to generate tones out of the PC speaker using Foxpro 9? I want to create a feature that will generate DTMF tones (phone dialing tones) to the speaker. If you hold the phone handset to the speaker, it should dial the number automatically. I need programmable way of generating them so that I can plug any phone number into the routine and have it beep out the number. Any ideas?

Thanks.
 
I suppose you could use the SET BELL command to run a wav file for each tone?


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Do you have access to old FoxPro Advisor issues? I wrote about handling sound from VFP apps in the November, 2001 issue.

Tamar
 
"If you hold the phone handset to the speaker, it should dial the number automatically."

That is certainly one way to do things, but it seems pretty awkward to me.

Why not use TAPI or Modem control within your VFP application along with a properly equipped phone to have the computer just dial directly for you?

If you still want to do it, you can always use something like this OLD routine I wrote WAY back when.

Making the appropriate modifications to meet your needs should be easy as long as you know which Tone WAV file to play and how long to play it for each phone number digit.

Code:
FUNCTION NiceChime
lcOS = OS(1)
SET BELL ON

IF lcOS = "NT";
      OR VAL(lcOS) >= 5
   mcCordWav = ""

   DO CASE
      CASE FILE('C:\WINNT\Media\Notify.WAV')
         mcCordWav = 'C:\WINNT\Media\Notify.WAV'

      CASE FILE('C:\WINNT\Media\Cord.WAV')
         mcCordWav = 'C:\WINNT\Media\Cord.WAV'

      CASE FILE('C:\WINDOWS\Media\Notify.WAV')
         mcCordWav = 'C:\WINDOWS\Media\Notify.WAV'

      CASE FILE('C:\WINDOWS\Media\Cord.WAV')
         mcCordWav = 'C:\WINDOWS\Media\Cord.WAV'
   ENDCASE

   IF !EMPTY(mcCordWav)
      SET BELL TO mcCordWav
      ??CHR(7)
   ENDIF
ELSE
   SET BELL TO 2600,3     && High note
   ??CHR(7)

   SET BELL TO 2200,3     && Middle note
   ??CHR(7)
ENDIF

SET BELL TO
SET BELL OFF
RETURN .T.

Good Luck,
JRB-Bldr
 
Another option would be to use the Beep() function:

Code:
* Do this at the start of the program:
DECLARE INTEGER Beep IN WIN32API ;
  INTEGER nFreq, INTEGER nDuration

* .......

* Do this when you want to beep:
Beep(256, 100)   && 256 Htz tone for 100 ms
Beep(1024, 500)  && 1024 Htz tone for 500 ms
* etc

But I agree with JRB-Bldr that it's an odd way to dial a number. It reminds me of the days of accoustic couplers (not to mention those whistles that came in cereal boxes; anyone remember what they were called?)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
The thing about DTMF tones is they are actually two tones played at once, and FoxPro is only able to play one tone at a time through the PC speaker.
I'm guessing you will have to do something like record the tones as individual .WAV files, then play them using something along the lines of JRB-Bldr's code.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Thanks for all your help, guys. It looks like if I have to play two tones at once, as with DTMF tones, I will have to play some pre-recorded sound file for the desired interval.

It's either that, or use a modem.

Sorry, Tamar, I don't have the Nov. '01 back issue of FoxPro Advisor. I may start to subscribe.
 
While I still think that physically holding a telephone handset up to a computer speaker so that the computer can dial a number is a poor way to do it, if you are set on using that method, the following might help.

To get working WAV files for each separate number to be dialed you could try to record them yourself from your own phone. Be aware that, due to input microphone and phone speaker quality, the resultant quality of the recorded audio signal MIGHT not be adequate to work - you would have to test the results.

Or you could look on the web for existing audio files.
This link might have the file(s) you are looking for.
TELEPHONE DIAL TONE, BUTTONS 1 - 9

Good Luck,
JRB-Bldr
 
I just remembered I built a computerized phone dialer as a project in college. I should be able to extract decent phone codes directly from there.

Anyways, thanks for all your help. I'll let you know if I get the thing working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top