BeepEx - A Beep for all Windows

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math Topics]   [Library]   [Utilities]

 

Search

 

Search DelphiForFun.org only

Support DFF

 If you shop at Amazon anyway,  consider using this link. We receive a few cents from each purchase.   Thanks.

In Association with Amazon.com

 

Support DFF

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

 

 

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

 

Search DelphiForFun.org only

 

 

 

 

Windows has a synchronous Beep function which allows the caller to specify the frequency and duration of the beep.   Synchronous means that the function does not return until the beep has ended.   Unfortunately, the function ignores frequency and duration if called from Windows 95, 98 or ME.   Even worse, the function operate asynchronously, i.e. it returns immediately.  If the program needs to sound multiple beeps, there is no way to know when the first beep has completed so that the second can begin.     

Here's a program that addresses the situation with a BeepEx procedure that  synchronously plays sounds of a specified frequency and duration under all Windows operating systems.   

The key is to directly address the PC Speaker with a small bit of assembly language code which I found in a unit named BleeperBleeper is one unit in a freeware download by Andy Preston named BleeperInt available from Torry.net and a few other places.   Bleeper is also included with this demo.  .

The demo allows users to set a frequency and duration and sounds the appropriate beep when a button is clicked.  A second button plays a major scale starting at the specified frequency and playing each note for the specified duration.    

Radio group buttons allow you to test the  Windows version of Beep vs. the new BeepEx.  For Windows  NT. 200 and XP, there should be no difference.  For lower Windows versions, a big difference!  

Addendum April 13, 2007:   Viewer Samuel from one of my favorite European countries, The Netherlands, recently sent me the numeric codes for a Minor scale and said that he was working on a full 88 key piano keyboard.  That may exceed the capacity of a PC speaker to reproduce, but I wish him luck.   I added it and a chromatic scale today.   Also added a "melody player" procedure, PlayTune, which takes an array  integer pairs representing the frequency and duration of each note.   Now if someone just writes a "tune editor" it could play more than one song.  

Download Source Code

Download Executable

Created: February 23, 2004

Modified: November 07, 2008

 

 

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2014, Gary Darby    All rights reserved.