Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to replace Windows.Beep with modern beep sound

Tags:

delphi

how to replace Windows.Beep with modern beep sound that comes from speakers with adjustable volume?

like image 848
Tom Avatar asked Jun 15 '10 07:06

Tom


3 Answers

Funny you should ask. I was just reading about the history of the windows beep. The Americans with Disabilities act has forced the Beep API to not change for the last 20 something years.

Link

For Windows 7, we resolved the issue completely – we moved all the functionality that used to be contained in Beep.Sys into the user mode system sounds agent – now when you call the Beep() API instead of manipulating the 8254 chip the call is re-routed into a user mode agent which actually plays the sounds.

So the short answer is: Get Windows 7. A longer answer would be: Don't use the beep api. Get a beep noise and play it like you'd play any other noise.

like image 142
Spike Avatar answered Nov 20 '22 02:11

Spike


If you want to use the "standard" beeps used by Windows when a MessageBox is displayed, you can call Windows.MessageBeep(MessageID) where MessageID maps to the same values as the icon ids for MessageBox (MB_OK, MB_ERROR etc).

One problem with this is that users can map any, or no sound to particular ids.

like image 10
Gerry Coll Avatar answered Nov 20 '22 02:11

Gerry Coll


Try this one

uses MMSystem;

procedure TForm1.Button1Click(Sender: TObject);
begin
  sndPlaySound('C:\Windows\Media\sound.wav',
    SND_NODEFAULT Or SND_ASYNC Or SND_LOOP);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  sndPlaySound(nil, 0); // Stops the sound
end;
like image 9
Bharat Avatar answered Nov 20 '22 02:11

Bharat