Control of PC Speaker in Delphi.
Make your programs bleep like FractInt.
Play tunes in the style of GWBasic's Play Statement.
Copyleft Andy Preston, Apollo Developments, 1999.
For more details, check out Andy's Anorak
This is Free Software,
released under the LGPL (Copy Enclosed).
OSI Certified
Open Source Software.
Delphi 1, 2, 3, and 4; C++ Builder 1, 3, and 4.
You must create your own bleeper.hpp, bleepint.hpp, and gwbleep.hpp file; to do this, load and compile the demo program. If you are updating a previous version of BleepInt, delete your old bleepint.hpp file first.
First, copy Bleeper.pas to your library directory.
You can use DoBleep, BleepPause, and ShutUp thus:
In Delphi:
Implementation Uses Bleeper; Procedure HurtMe; { Play a nasty high pitched note } Begin { Don't stop until you're told to } DoBleep (1000, -1); End; Procedure MakeItStop; { Stop whatever sound is being produced } Begin ShutUp; End; Procedure PlayTune; { Play some nice tones of set duration } Begin { The people of Earth call it music. } DoBleep (146, 250); BleepPause (10); DoBleep (123, 250); BleepPause (10); DoBleep (164, 500); BleepPause (10); DoBleep (123, 500); End;
In C++Builder
#include <mylib/bleeper.hpp> void HurtMe { // Play a nasty high pitched note DoBleep (1000, -1); // Don't stop until you're told to } void MakeItStop { // Stop whatever sound is being produced ShutUp; } void PlayTune { // Play some nice tones of set duration DoBleep (146, 250); // The people of Earth call it music. BleepPause (10); DoBleep (123, 250); BleepPause (10); DoBleep (164, 500); BleepPause (10); DoBleep (123, 500); }
The specification of DoBleep (until version 4.5) was:
Procedure DoBleep (Freq : Word; MSecs : Integer);As of version 4.5 it is:
Procedure DoBleep (Freq : Word; MSecs : LongInt);This will only affect your 16-bit code (in 32-bit code an Integer is the same as a LongInt), and I don't think it will make a lot of difference to that either, but you have been warned.
First, copy Bleeper.pas and BleepInt.pas to your library directory.
You can use Bleep thus:
In Delphi:
Implementation Uses BleepInt; Procedure FractintBeeps; Begin Bleep (bOK); Bleep (bInterrupt); Bleep (bError); End;
In C++ Builder:
#include <mylib/bleepint.hpp> void FractintBeeps { Bleep (bOK); Bleep (bInterrupt); Bleep (bError); }
First, copy Bleeper.pas and GWBleep.pas to your library directory.
You can use Play thus:
In Delphi:
Implementation Uses GWBleep; Procedure PlayAScale; Begin PlayBleep ('L4<BPCPC+PDPD+PEPFPF+PGPG+PAPB-PBP>C'); End; Procedure PlayATune; Begin PlayBleep ('L2D4<B4E<BP8C#8D4<B4E<BP8C#DGF#GEL4D<BEE<B1') ; End;
In C++ Builder:
#include <mylib/gwbleep.hpp> void PlayAScale { PlayBleep ('L4<BCC+DD+EFF+GG+AB-B>C'); } void PlayATune { PlayBleep ('L2D4<B4E<BP8C#8D4<B4E<BP8C#DGF#GEL4D<BEE<B1') ; }
The command strings used by PlayBleep are a subset of those used by the old GWBasic Play statement.
The commands implemented so far are:
See Demo.dpr, Demo1.dfm, And Demo1.pas (included in this archive) for more information.
or for the C++Builder fans, see CBDemo.mak, CBDemo.cpp, CBDemo1.dfm, CBDemo1.cpp, And CBDemo1.h
If there's a C++Builder dude out there who can remove all references to CDDemo.res from CBDemo.mak, please E-Mail me (Andy Preston) so I can include your modified version
My customer needed a set of warning bleeps in his application, he didn't have a sound card (not much use in a kitchen!), and Windows' built-in (and rathe r sad) dit was no use at all.
I got hold of the TPCSpeaker component by Song Weng Sam from The DSP. But I thought a simple beeper was best implemented as a set of stand-alone procedures.
I was in the process of hacking TPCSpeaker into such a set of routines
when I came across an ancient copy of the FractInt source (Version 7.0
I think) which contained assembly source for the classic FractInt 'do-do-doop'.
So what we started with was a mixture of Song Weng Sam's delay loop, and a rather cut down version of FractInt's sound routines.
Since that time, many of you have added new facilities, and fixed bugs in BleepInt. The result is the only speaker driver you'll ever need.
If you've got any fab-and-groovy modifications for Bleepint, please E-Mail me (Andy Preston).
FractInt, still the ultimate fractal generator, is a product of the Stone-Soup Group. I'm not sure which particular Stone-Souper was responsible for the bits I 've filched, so I can't give hir the credit sHe deserves, I'll just take my hat off (except I don't wear a hat) to the lot of them.
Thanks to:
If you've tested it with Delphi 3, Delphi 4, C++ Builder, or on NT, please E-Mail me (Andy Preston) and let me know. Then I can update this.
OSI Certified is a certification mark of the Open Source Initiative. Delphi and C++Builder are trademarks of Inprise International, GWBasic is a trademark of Microsoft corp.