I made this for my amusement to use while playing semi-afk or to alert me when encountering a random.
Here's the API:
The first two are the beeping functions you should use.Code:function Beep(freq, duration: ShortInt): Boolean;
function MessageBeep(id: Word): Boolean;
function BEEP_SIMPLE(): Word;
function BEEP_ERROR(): Word;
function BEEP_WARNING(): Word;
function BEEP_QUESTION(): Word;
function BEEP_INFORMATION(): Word;
function BEEP_OK(): Word;
Beep is a hardware beep requiring an 8254 sound chip which may not work on newer computers which don't have the chip. If there is hardware support, it will beep even if software sound is disabled (unless hardware sound is also disabled). Beep will not work in Vista or XP 64-bit machines.
The frequency is in Hertz and ranges between 37 through 32,767. The duration is in milliseconds.
MessageBeep is a software beep that uses the standard Windows sounds you have set up in your control panel. To get there, go to Control Panel -> Sounds -> Sounds tab. The argument is the return value of one of the six BEEP_NAME functions listed above [I have them as functions rather than constants because Simba can only import DLL functions, not data, but if you leave off the parentheses it's just the same for scripting.].
Control Panel sound correspondence (to change the sounds):
- BEEP_SIMPLE: May not be changed. You can use this if you want to make sure that the sound is heard regardless of Control Panel configuration.
- BEEP_ERROR: Windows Critical Stop.
- BEEP_WARNING: Windows Exclamation.
- BEEP_QUESTION: Windows Question.
- BEEP_INFORMATION: Windows Asterisk.
- BEEP_OK: Windows Default Beep.
BEEP_SIMPLE may not be changed. You can use this if you want to make sure that the sound is heard regardless of Control Panel configuration.
Both beep functions return false if they fail, or true if they succeed. If you call MessageBeep with an argument other than those provided in the six BEEP_NAME functions, it will return false, though it may play a sound nonetheless.
Here is a testing script to try out the plugin:
To install, place the attached DLL in your Plugins directory. The DLL is for use with 32-bit Simba only. This shouldn't matter much since 64-bit Simba is a buggy piece of trash anyway :)Code:{Aftermath 11/22/11}
program BeepDemo;
var success: Boolean;
var freq, duration: ShortInt;
{$Loadlib SimbaBeep}
begin
freq := 750;
duration := 300;
WriteLn('Beep Test');
success := Beep(freq, duration);
WriteLn('Hardware beep: ' + BoolToStr(success));
Wait(1000);
success := MessageBeep(BEEP_SIMPLE);
WriteLn('Software beep SIMPLE: ' + BoolToStr(success));
Wait(1000);
success := MessageBeep(BEEP_ERROR);
WriteLn('Software beep ERROR: ' + BoolToStr(success));
Wait(1000);
success := MessageBeep(BEEP_WARNING);
WriteLn('Software beep WARNING: ' + BoolToStr(success));
Wait(1000);
success := MessageBeep(BEEP_QUESTION);
WriteLn('Software beep QUESTION: ' + BoolToStr(success));
Wait(1000);
success := MessageBeep(BEEP_INFORMATION);
WriteLn('Software beep INFORMATION: ' + BoolToStr(success));
Wait(1000);
success := MessageBeep(BEEP_OK);
WriteLn('Software beep OK: ' + BoolToStr(success));
end.
I've attached the source. You'll need to make a Win32 DLL project in Visual Studio, and use the .def file for the module definition.

