We help IT Professionals succeed at work.

Beep sound

zhuhail asked
Last Modified: 2008-02-26
I know how to do beeps with various frequencies and durations in Visual Basic and the code was working on windows 3.1 and 95.

However, I feel it is more difficult in Delphi (should
be better than Visual Basic):

People said we may use Windows.Beep(frequency, duration)
in Windows NT (but not in Windows 3.1, I think), I have
tried to use it in Windows 95. It was working anyway but
was only a simple beep. When I change the frequency from
99 to 999999999 and change the duration from 99 to
999999999, the sounds remained the same!

Can you give me the right code for that (better for both
NT and 95)?
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)


Thank you for your help.

You are right...that may not wrok in Win95 and I want you give me a right code :-)
Perhaps we can do beeps with designed frequency and duration in Win95 by calling API functions. That is what I did in Visual Basic....Or, do you think Win95 not supports the API functions for beep sound anymore? Can we still call such API functions of 16 bit from Win95?


OK I've just had a bit of a play with Beeps and this is the score:

There is a Delphi Beep Command Defined in SysUtils. If you have SysUtils in your Uses clause then Calling Beep will call this function. This function takes no parameters and if you try and put any in the call you will get an error. This function makes a simple beep sound using the internal speaker.

There is also an API call Beep. This call takes two parameters and can only be called directly if you remove SysUtils from the Uses clause, (otherwise you are calling the Delphi Beep function). The previous comments about this Beep command in win95 still stand. I don't have NT so I can't test what happens, but in 95 the API Beep function plays the Default Sound Wave, or a simple beep if no sound card is installed.

  I'm afraid I can't help you concerning 16 bit technology, it's out of my scope of knowledge, however I can tell you with some certainty that using the beep command in Win95 will never produce more than the one simple boring beep.

  Why do you need this functionality?



I am so sad when I reading your comment :-(
This is the first thing I found that Win3.1 better then Win95.

Why I need such beeps? In Visual Basic, using such beeps, I made some very simple, but nice music in a game which is written under Win3.1 (without the sound card) but stil works under Win95.


 The thing about the Beep command is that it is only really intended for use as a warning sound (It is included as part of the Error processing functions). I don't know what sort of code was generated by Visual Basic such that your Application ported from 3.1 to 95 but I can only presume that it doesn't use the API Beep function. I havn't come accross a call that will allow the sort of wave generation that you are looking for in Win95, if it is possible then I suspect that it will require a lot of fiddly code and I don't know how it's done I'm afraid. I would stick to using sampled sounds for your games applications (Investigate the PlaySound API Call).
  Sorry to be so negative, feel free to reject this answer if you feel someone else might have a more satisfying answer for you.

Hi zhuhail here is keksperte

don't beleave them if they say impossible.

here is my solution:

   This is a workaround to create some tones other than the BEEP in Delphi
   (and other IDE's).  It's not DELPHI but it works, is flexible and it's free.

1. Create a link from the good old QBASIC.EXE and move it to the C:\tmp DIR
    and name it BEEPER
   (You will find QB in the C:\WIN95\Command or C:\WINNT\System32 Dir.)

   Enter on the programtab the comandline
     C:\WIN\COMMAND\QBASIC.EXE /RUN C:\tmp\MoreBeep.bas
   for the workingdir
   Also you can use a very small font (see fonttab, Sysfont 2x4)
   On screentab select standard window with restore params on restart so that the last
   windowposition will be saved

2. Create with the NOTEPAD or directly in QBASIC the following BasicCode:

   PLAY "MBT180o2P2P8L16CEGL8>CP64"
   WHILE PLAY(0) > 0: WEND
   rem 4 more help on PLAY press F1-Button or ALT+H in QB

   Save this code as 'MoreBeep.bas'

3. Create a new delphi project with a button.

4. Define in the ButtonClick procedure the following command:

   procedure TForm1.Button1Click(Sender: TObject);
     ShellExecute(Application.Handle, nil, 'Beeper', '', 'C:\tmp', SW_SHOW);

5. Compile the project and run. On Click you will hear the hevently sound on the speaker.

6. To hide the QB-Window you can use on WINNT the SW_SHOWMINIMIZED command     in the above ClickProcedure. On WIN95 it seams that the only way is to put the window
   near the border or under the TASK-BAR so that you can't see it at runtime.

So, that's it. I hope you'll become a great musican.


Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.