Fog Creek Software
g
Discussion Board




Beep

What still alludes me is the setting for the system beep. What is it that controls whether the beep will sound or not?

I used the Beep function from the VBA library. It works only on some systems. Then I used the Beep API. No luck! Worked on some more systems, but not on all. Then I added a call to SystemParametersInfo API to check the beep setting on the system, turn it on, play the beep API and restore the system beep setting to its previous state.

Have a look!


Public Sub SoundBeep()

Dim BoolPreviousBeepState As Boolean
Dim LngRetVal As Long
   
    LngRetVal = SystemParametersInfo(SPI_GETBEEP, BoolPreviousBeepState, 0&, CLng(False))
    Debug.Assert LngRetVal <> 0
    LngRetVal = SystemParametersInfo(SPI_SETBEEP, True, 0&, CLng(False))
    Debug.Assert LngRetVal <> 0
   
    BeepAPI 400, 200
    BeepAPI 600, 300
    BeepAPI 500, 300
   
    BeepAPI 400, 200
    BeepAPI 600, 300
    BeepAPI 500, 300

    LngRetVal = SystemParametersInfo(SPI_SETBEEP, BoolPreviousBeepState, 0&, CLng(False))
    Debug.Assert LngRetVal <> 0
   
End Sub


It works like a charm. But when I now change the method of calling for the Beep from the API to the VBA libraries Beep function available to Visual Basic, I hear no beep.

Then I play with enumerating the devices on the system by calling auxGetNumDevs. I want to be able to set the volume of the beep to a lowder tone, so I call auxSetVolume from winmm.dll. When I almost am able to raise the volume to a certain level, it is still not very satisfying. But I fail to have a complete control over the beep setting and its volume. What sucks is that auxSetVolume does nothing to change the volume of the output produced by VB's Beep function where the function works. It has only little effect on those systems I play the Beep API on. And on some computers, the Beep auxGetNumDevs returns 0 devices even though the Beep API works on those.

What's the mystery behind the system beep?

Sathyaish Chakravarthy
Wednesday, October 8, 2003

Wasn't beep something like Print Chr$(7)?

How did something so simple get so complicated?  Somtimes I miss the old days...of a few years ago!  :-)

Greg Kellerman
Wednesday, October 8, 2003

Sathyaish Chakravarthy: So what you're saying is that if the user turned off beeps, you're going to turn them on, beep, and then restore their preference? You will explicitely go against the user's wishes? That's amazingly rude.

Troy King
Wednesday, October 8, 2003

I for one would enjoy a general discussion on how simple things have become unnecessarily complex for no good reason other than gratuitous complexity.

Dennis Atkins
Wednesday, October 8, 2003

Troy, don't underestimate them thar users.  They can be pretty ingenious.  Heck, if you piss them off they just might open the computer case and unplug that damn speaker!

Greg Kellerman
Wednesday, October 8, 2003

Its the software. Install NT4 and it will beep like crazy, install 2000 and it beeps a bit less but still gets annoying, install XP and I can't make it beep if my life depended on it.

My theory is there is a guy in redmond who is just as annoyed at the beeping as everybody else and has been slowly disabling the beep functionality until finally it doesn't exist and nobody noticed because he did it so slowly over a few releases.

ChrisO
Thursday, October 9, 2003

Troy, I wouldn't bother with all that labour if it was going to bug the user. I'd rather have it simple as a single call to the Beep function. But it so turns out that the application this code comes from is to raise alerts to the user to remind him of a scheduled event, through a beep if he'd chosen this method of reminder. This would call for a beep, and a melodious one in that, on the appropriate time. If I had the choice, I could have done with a "silent beep" in line with your suggestion. The user can't have the cake and eat it too.

Sathyaish Chakravarthy
Thursday, October 9, 2003

Dennis (the menace) writes,
"I for one would enjoy a general discussion on how simple things have become unnecessarily complex for no good reason other than gratuitous complexity."

Dennis, how would you define "gratuitous complexity"?

Sathyaish Chakravarthy
Thursday, October 9, 2003

Greg, what was it about Chr(7)? I am intrigued.

Sathyaish Chakravarthy
Thursday, October 9, 2003

Well, Chris, I am just begining to notice.

Sathyaish Chakravarthy
Thursday, October 9, 2003

ASCII value 7 is the vaule for the system bell.  Used to ring it in the original star trek game which ran on a teletype device.  Bing-bing-bing.  Drove the teacher crazy or anyone else trying to think.

nat ersoz
Thursday, October 9, 2003

And in Visual FoxPro all you had to do to make a beep was go "? CHR(7)" and it would beep.

ChrisO
Thursday, October 9, 2003

Rather than all that playing around with the beep (and possibly overriding the user's settings) why not let the user nominate a .WAV file to be played as their alert, with an option of setting it to "(none)"?

Andrew Lighten
Thursday, October 9, 2003

Um, is this a DOS application, or what?

If you're creating a Windows application, use the API to play either a system sound or your own application-defined sound (which can then be managed by the user via the Control Panel).

The beep is dead in Windows.

Dave

Dave
Thursday, October 9, 2003

How about playing WINNT\Media\ding.wav ?

John Ridout
Thursday, October 9, 2003

Without mentioning that lots of people have their PC cases below desktop level. The other day I installed an amazingly stupid application that beeped all along the way (onmouseover, onmouseout if you believe it) but I didn't hear it until several minutes.

Leonardo Herrera
Thursday, October 9, 2003

"gratuitous complexity" is when something is complex for complexities sake and teh complexity serves no benefit. An example is the code given to try to play a bell, which is much more complex than outputting ASCII 7, or perhaps calling "SystemBeep()", or some other simple one-line routine.

I am seeing the case where things are getting more complex with each release and the complexity doesn't serve any practical purpose. An example might be some API function that has sensible defaults but requires you to pass 23 parameters to it, including 4 callback functions, each of which needs a custom event handler for communicating with the mother-ship function during a certain execution mode, 2 of the callbacks of which are expected to maintain sub-callbacks with their own protocols.

Dennis Atkins
Thursday, October 9, 2003

I used an addressing DLL (for postal addresses).  It had a single function call. It took four parameters, each was a char(200).  The one function actually served several functions with the meaning of the four parameters changing for each function.  The real parameters were placed into the character strings at various points, which also changed according to the actual function. One horribly complex function call instead of several simple calls.

John Ridout
Thursday, October 9, 2003

Gratuitous Complexity:

When you spend more time discussing the architecture than solving the problem.

nat ersoz
Thursday, October 9, 2003

*  Recent Topics

*  Fog Creek Home