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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why no sound when ? chr(7) in VFP8?

Status
Not open for further replies.

normanhk

Programmer
Oct 4, 2003
15
HK
I used to use the following way to play sound files in VFP3. It is perfectly OK. But when I update to VFP8, the old codes give no sound at all.

SET BELL TO abc.wav
?? CHR(7)
SET BELL TO

One strange thing I have observed is that it fails to give sound only if there is a FORM running (after DO FORM xxxx). Without any form, it can still play the sound file. I have search the online documents but it doesn't give me any hint.
Of course I am using _soundplayer now to play sound in VFP8 but the effect is BAD. The sound cannot synchronise with the picture frequently. This never happens when I use the old method in VFP3.
 
Ramani, thank you for your reply.

Actually I have tried both ? and ??. Both do not work. I am using Windows XP Pro with all the updates done.

Regards,
Norman
 
Norman,

I put in a commandbutton click in a form..

SET BELL TO GETFILE("WAV")
? CHR(7) && not '??'
SET BELL TO

It sounded.

Probably, the file path is relative and when you run the form it is not working. SO change the code as given above and select the wave file and try, if that works. Make sure the volume is set properly for the sound wave types. :)

ramani :)
(Subramanian.G)
 
Ramani,

I have tried exactly what you mentioned but no sound again. Are you really using VFP8 (I have found no problem in any previous versions) in Windows XP Pro? If yes, I start to puzzle anything wrong about my computer.

Best regards,
Norman
 
Ramani,

Sorry to border you again. My case is: exactly the same thing gives sound in VFP3 but no sound in VFP8, in the same computer and same time. Even the simpliest form with a single button behaves like this. So I don't think that it is a problem of path and coding.

Best regards,
Norman
 
This is what I used.. both in GUI and code way.
Chose c:\windows\media\tada.wav and ringout.wav
**************************************************
PUBLIC oform2

oform2=NEWOBJECT("form2")
oform2.Show
RETURN

**************************************************
*-- Form: form2 (d:\winners7\gl\form2.scx)
*-- ParentClass: form
*-- BaseClass: form
*-- Time Stamp: 10/05/03 12:53:12 PM
*
DEFINE CLASS form2 AS form

DoCreate = .T.
Caption = "Form2"
Name = "form2"

ADD OBJECT cmdsound AS commandbutton WITH ;
Top = 168, ;
Left = 36, ;
Height = 27, ;
Width = 84, ;
Caption = "Sound", ;
Name = "cmdSound"

PROCEDURE cmdsound.Click
SET BELL TO GETFILE("WAV")
? CHR(7)
SET BELL TO
ENDPROC

ENDDEFINE
*
*-- EndDefine: form2
**************************************************


ramani :)
(Subramanian.G)
 
normanhk,

Cut-N-Paste the code below into a prg file and run it from with VFP 8 on Windows XP. Does it work for you?

PUBLIC oForm
oForm = CREATEOBJECT("clsbeepwave")
oForm.show()

DEFINE CLASS clsbeepwave AS form

DoCreate = .T.
Caption = "Form1"
Name = "Form1"

ADD OBJECT command1 AS commandbutton WITH ;
Top = 84, ;
Left = 144, ;
Height = 27, ;
Width = 84, ;
Caption = "Command1", ;
Name = "Command1"

PROCEDURE command1.Click
SET BELL TO "C:\Windows\Media\tada.wav"
? CHR(7)
SET BELL TO
ENDPROC

ENDDEFINE


Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
[bigsmile] ramani you are quicker with the Submit Post button than I am!

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Hi ramani & slighthaze,

Thank you again. I have try slighthaze's code but it does not work. When I comment the line "SET BELL TO", I can play the sound after I close the form (type ? CHR(7) in command window).
If all of you find that it works, I start to suspect my sound card driver (Audigy Platinum).
So I supected that there is something clash in my Windows. If I have time, I will try to rebuild my Windows (Oh! That needs a crazy long time!)

Best regards,
Norman
 
Hi everybody,

Finally I have make an exe. The exe gives sound in another computer. But the same exe cannot give sound in my computer still. So it is certainly a clash of something. If I have time I will try to identify the thing that cause the clash. Anyway the problem is already solved if it works in other computers as my program is usually run by others.

Best regards,
Norman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top