📄 bleepint.htm
字号:
<HTML><HEAD><TITLE>Bleeper / BleepInt / GWBleep</TITLE><LINK REV="made" HREF="mailto:andy@anorak.org.uk"><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"></HEAD><BODY BGCOLOR="#000000" TEXT="#00FF00" LINK="#FFFFFF" ALINK="#FFFF00" VLINK="#00FFFF"><H1 ALIGN="CENTER">Bleeper / BleepInt / GWBleep<BR>Version 5.5</H1><UL><LI>Control of PC Speaker in Delphi. (Now with Turbo Pascal Compatability)</LI><LI>Make your programs bleep like FractInt.</LI><LI>Play tunes in the style of GWBasic's Play Statement.</LI></UL><CENTER><P><A HREF="http://www.gnu.org/copyleft/copyleft.html">Copyleft</A>Andy Preston, Apollo Developments, 1999, 2000.</P><P>For more details, check out<A HREF="http://www.apollod.omnia.co.uk/aa/">Andy's Anorak</A></P><H2><FONT COLOR="#FF0000">Bug Alert</FONT></H2></CENTER><P><FONT COLOR="#FF0000">Under Windows NT, <STRONG>DoBleep</STRONG>with a duration parameter of -1 does not produce a continuous soundas it should. This also means that <STRONG>Sound</STRONG> also actsstrangely.</FONT></P><P>If there's an NT boffin out there who can fix this bug please get intouch</FONT></P><H2 ALIGN="CENTER">Licensing</H2><P>This is <A HREF="http://www.gnu.org/philosophy/free-sw.html">Free Software</A>,released under the LGPL (Copy Enclosed).<BR><A HREF="http://www.opensource.org/certification-mark.html">OSI Certified</A>Open Source Software.</P><H2 ALIGN="CENTER">Platforms</H2><UL><LI>Delphi 1, 2, 3, 4, & 5</LI><LI>C++ Builder 1, 3, 4, & 5.</LI><LI>Windows 3.1, 3.11, '95, '98, M.E.</LI><LI>Windows NT 3, 4, 5, 2000</LI></UL><CENTER><H2>Use</H2><H3>C++ Builder Note</H3></CENTER><P>You must create your own <STRONG>bleeper.hpp</STRONG>,<STRONG>bleepint.hpp</STRONG>, and <STRONG>gwbleep.hpp</STRONG> file;to do this, load and compile the demo program. If you are updating aprevious version of BleepInt, delete your old <STRONG>bleepint.hpp</STRONG>file first.</P><H3 ALIGN="CENTER">Speaker Control</H3><P>First, copy <STRONG>Bleeper.pas</STRONG> to your library directory.</P><P>You can use <STRONG>DoBleep</STRONG>, <STRONG>BleepPause</STRONG>, and<STRONG>ShutUp</STRONG> thus:</P><P>In Delphi:<PRE> 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;</PRE></P><P>For Turbo Pascal compatibility you can use <STRONG>Sound</STRONG>,and <STRONG>NoSound</STRONG> thus:<PRE> Implementation Uses Bleeper; Procedure HurtMe; { Play a nasty high pitched note } Begin { Don't stop until you're told to } Sound (1000); End; Procedure MakeItStop; { Stop whatever sound is being produced } Begin NoSound; End; Procedure PlayTune; { Play some nice tones of set duration } Begin { The people of Earth call it music. } Sound (146); Delay (250); NoSound; Delay (10); Sound (123); Delay (250); NoSound; Delay (10); Sound (164); Delay (500); NoSound; Delay (10); Sound (123); Delay (500); NoSound; End;</PRE></P><P>In C++Builder:<PRE> #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); }</PRE></P><H3>Warning - Compatability with earlier versions</H3><P>The specification of <STRONG>DoBleep</STRONG> (until version 4.5) was:<PRE>Procedure DoBleep (Freq : Word; MSecs : Integer);</PRE>As of version 4.5 it is:<PRE>Procedure DoBleep (Freq : Word; MSecs : LongInt);</PRE>This will only affect your 16-bit code (in 32-bit code an<STRONG>Integer</STRONG> is the same as a <STRONG>LongInt</STRONG>),and I don't think it will make a lot of difference to that either,but you have been warned.</P><H3 ALIGN="CENTER">Fractint Bleeps</H3><P>First, copy <STRONG>Bleeper.pas</STRONG> and<STRONG>BleepInt.pas</STRONG> to your library directory.</P><P>You can use <STRONG>Bleep</STRONG> thus:<P>In Delphi:<PRE> Implementation Uses BleepInt; Procedure FractintBeeps; Begin Bleep (bOK); Bleep (bInterrupt); Bleep (bError); End;</PRE></P><P>In C++ Builder:<PRE> #include <mylib/bleepint.hpp> void FractintBeeps { Bleep (bOK); Bleep (bInterrupt); Bleep (bError); }</PRE></P><H3 ALIGN="CENTER">Playing tunes</H3><P>First, copy <STRONG>Bleeper.pas</STRONG> and<STRONG>GWBleep.pas</STRONG> to your library directory.</P><P>You can use <STRONG>Play</STRONG> thus:<P>In Delphi:<PRE> 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;</PRE><P>In C++ Builder:<PRE> #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"); }</PRE></P><P>The command strings used by <STRONG>PlayBleep</STRONG> are a subsetof those used by the old GWBasic <STRONG>Play</STRONG> statement.</P><P>The commands implemented so far are:</P><UL><LI><STRONG>P,A,B,C,D,E,F,G [#,+,-]</STRONG> A-G are the notes,a # or + after a note makes it sharp, a - after a note makes it flat.<BR><STRONG>P</STRONG> is special, it does not sound a note, it is forinserting pauses into the tune.</LI><LI><STRONG>Ln</STRONG> Sets the length of the notes, L4 is a quarter note,L1 is a whole note<BR>To set the duration of one note, you can put the duration after that note,as in the <STRONG>PlayATune</STRONG> example above</LI><LI><STRONG>On</STRONG> Sets the octave in the range 1..7.The default octave is 4. Middle C is at the beginning of octave 3</LI><LI><STRONG>MN</STRONG> Music normal, each note plays for<SUP>7</SUP>/<SUB>8</SUB> of it's duration, followed by a pause of<SUP>1</SUP>/<SUB>8</SUB> it's duration.</LI><LI><STRONG>MS</STRONG> Music staccato, each note plays for ¾ of it'sduration, followed by a pause of ¼ it's duration.</LI><LI><STRONG>ML</STRONG> Music legato, each note plays for it'sfull duration.</LI><LI><STRONG>></STRONG> Plays the next note only, one octave higher</LI><LI><STRONG><</STRONG> Plays the next note only, one octave lower</LI></UL><P>See Demo.dpr, Demo1.dfm, And Demo1.pas (included in thisarchive) for more information.</P><P>or for the C++Builder fans, see CBDemo.mak, CBDemo.cpp,CBDemo1.dfm, CBDemo1.cpp, And CBDemo1.h</P><P>If there's a C++Builder dude out there who can remove all references to<STRONG>CDDemo.res</STRONG> from <STRONG>CBDemo.mak</STRONG>, please E-Mail me(<A HREF="mailto:andy@anorak.org.uk">Andy Preston</A>) so I caninclude your modified version</P><H2 ALIGN="CENTER">The Story</H2><P>My customer needed a set of warning bleeps in his application, he didn'thave a sound card (not much use in a kitchen!), and Windows' built-in (and rathersad) <EM>dit</EM> was no use at all.</P><P>I got hold of the<A HREF="http://sunsite.icm.edu.pl/delphi/ftp/d10free/pcspk.zip">TPCSpeaker</A>component by Song Weng Sam from The DSP. But I thought a simplebeeper was best implemented as a set of stand-alone procedures.</P><P>I was in the process of hacking TPCSpeaker into such a set of routineswhen I came across an ancient copy of the FractInt source (Version 7.0I think) which contained assembly source for the classic FractInt 'do-do-doop'.<BR><CENTER><STRONG>Why not give my customer a bleep with realclass!</STRONG></CENTER></P><P>So what we started with was a mixture of Song Weng Sam'sdelay loop, and a rather cut down version of FractInt's soundroutines.</P><P>Since that time, many of you have added new facilities, and fixed bugsin BleepInt. The result is the only speaker driver you'll ever need.</P><P>If you've got any fab-and-groovy modifications for Bleepint, pleaseE-Mail me (<A HREF="mailto:andy@anorak.org.uk">Andy Preston</A>).</P><H2 ALIGN="CENTER">Thanks</H2><P><A HREF="http://archives.math.utk.edu/software/msdos/complex.variables/fractint/.html">FractInt</A>,still the ultimate fractal generator, is a product of the Stone-SoupGroup. I'm not sure which particular Stone-Souper was responsible for the bits I'vefilched, so I can't give hir the credit sHe deserves, I'll just take my hat off<EM>(except I don't wear a hat)</EM> to the lot of them.</P><P>Thanks to:</P><UL><LI>Hans Schneider, for help with Turbo Pascal Compatibility issues.</LI><LI>Thomas Roettgers for further Delphi 3 Testing and Compatabilityimprovements, Windows NT Support, and NT Parameter compatability[DoBleep (Freq, -1)]</LI><LI>Basri & Don Adaway for pointing out bugs in the NT code</LI><LI>P.Satyanarayana of VJIL Consulting India for spotting awarning message, when used with Delphi 4</LI><LI>Michl Ladislav for suggestions to shrink the size of32-bit Console Apps, saving 130K, and spotting the minorbug in HardBleep.</LI><LI>Roy Andrews, CS-Interglas Ltd, for pointing out therange check bug in Windows NT.</LI><LI>Uffe R. L. Stentebjerg, for getting me to work out aproper C++ Builder demo, and instructions.</LI><LI>Jack Stiles of SwiftTech Software, for <STRONG>finally</STRONG>,getting rid of P. Satyanarayana's warning message, and for eliminatinga rare bug in the delay loop: If the machine has been up-and-runningfor 49.7 days, the clock resets to zero (It's a bit like amini-'millenium bug'), Jack's new code 'notices' this has happenedand deals with it accordingly. Thanks also goes to Jack for helpingto convert the table of frequencies into a useful format</LI></UL><H2 ALIGN="CENTER">Testing</H2><P>If you've tested it with a higher version of Delphi, C++ Builder, or on NT,please E-Mail me (<A HREF="mailto:andy@anorak.org.uk">Andy Preston</A>)and let me know. Then I can update this.</P><UL><LI>Version 5.4 Tested by Apollo Developments on Delphi 1.02 and 2.0</LI><LI>Version 4.5 Tested by Jack Stiles of SwiftTech Software on Delphi 4.0</LI><LI>Version 4.1 Tested by Alan with Delphi 2.0 / <STRONG>NT 4 (SP 3)</STRONG></LI></UL><HR><P ALIGN="CENTER">This page has been checked by<A HREF="http://www.weblint.org">Weblint</A>, Version 1.020</P><P><SMALL><EM>OSI Certified</EM> is a certification mark of the Open SourceInitiative. <EM>Delphi</EM>, <EM>C++Builder</EM>, and <EM>Turbo Pascal</EM>are trademarks of Inprise International, <EM>GWBasic</EM> is a trademarkof Microsoft corp.</SMALL></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -