Solved

PC Speakers

Posted on 1998-06-08
8
522 Views
Last Modified: 2010-04-04
When I use the Beep procedure, it hardly gives a beep at all. How do I get a decent and loud BUZZ or BEEP from the PC Speakers?

(I am using the MessageBeep if the user's computer has a multimedia card, otherwise I have to use the PC speakers...)

Thanks in advance...

Keith
0
Comment
Question by:keithcsl
  • 4
  • 3
8 Comments
 
LVL 2

Expert Comment

by:kjteng
ID: 1351516
You may try the obsolete setSound API. eg
  i:=openSound;
  if i>0 then
    setVoiceSound( 1, iFrequency, iDuration));
  startSound;
  closeSound;

You must set the device= sound.drv in config.sys
0
 
LVL 1

Author Comment

by:keithcsl
ID: 1351517
kjteng

i am soryy but i should have mentioned that i am using Delphi 3. The procedures that you have given are not available anymore. Is there any other way to get a loud beep?

Keith
0
 
LVL 2

Expert Comment

by:kjteng
ID: 1351518
What about playing a wav file to speaker?
0
 
LVL 1

Author Comment

by:keithcsl
ID: 1351519
kjteng

well, that's is what i am doing now (playing a wave file), but it is only for users with sound card. i just wanted to add another feature in my software for those without sound card, that is beeping the pc speakers...

Keith
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 8

Expert Comment

by:ZifNab
ID: 1351520
Hi keithcsl, try out these functions which I got from the web a long time ago :

Making PC Speaker Sound


    Below are the procedures Sound, NoSound, and Delay. They are called in
    the same way that Turbo Pascal's Sound, NoSound, and Delay procedures are
    called. For example, to produce a 600 Hz tone for 200 milliseconds, you
    would call the procedures as follows:

       Sound(600);
       Delay(200);
       NoSound;

    procedure TForm1.NoSound;
    begin
       Port[$61] := Port[$61] and $FC;
    end;


    procedure TForm1.Sound(Freq : Word);
    var
       B : Byte;
    begin
       if Freq > 18 then
          begin
             Freq := Word(1193181 div LongInt(Freq));

             B := Port[$61];

             if (B and 3) = 0 then
                begin
                   Port[$61] := B or 3;
                   Port[$43] := $B6;
                end;

             Port[$42] := Byte(Freq);
             Port[$42] := Byte(Freq shr 8);
          end;
    end;


    procedure TForm1.Delay(MSecs : Integer);
    var
       FirstTickCount : LongInt;
    begin
       FirstTickCount:=GetTickCount;
       repeat
          Application.ProcessMessages; {allowing access to other controls,
                                        etc.}
       until ((GetTickCount-FirstTickCount) >= LongInt(MSecs));
    end;

    Author: Thomas Foster

    Regards, Zif.
0
 
LVL 2

Expert Comment

by:kjteng
ID: 1351521
Just for discussion purpose:
You still can play wav to pc speaker eventhough there is no soundcard: Just install a small speaker driver to the pc. That way, you do not need to have separate code for those user who has no sound card.

0
 
LVL 1

Author Comment

by:keithcsl
ID: 1351522
ZifNab

Delphi 3 does not allow me to access the ports directly, not like in Delphi 2...

kjTeng

Could you elaborate more on the speaker driver, ie hardware/software requirements?

Keith
0
 
LVL 2

Accepted Solution

by:
kjteng earned 30 total points
ID: 1351523
Frist: Install speaker Driver
==============================
1. Make sure that there is a speaker.drv file {some oem may have named it as speakr.drv, speaker.exe etc .. or may even supply you an installation disk with inf files}

2. Add the following to your system.ini file:
[boot]
sound.drv=mmsound.drv
[drivers]
wave=speaker.drv

3. Restart your windows.

4. Goto control panel - multimedia to set the speaker   volume,    Goto contol panel - sound to test the speaker sound.

5. If your speaker driver is installed correctly, the pc will play wav file through the speaker.


Second: play sound in delphi
=============================
Add "mmsystem" to the uses clause of your program file.
Call the API sndPlaySound to play wave, eg sndPlaySound('filename.wav', snd_NoDefault)  That's it!
(For more info on the sndPlaySound function, please check: delphi1:  mmsystem.hlp file in you delphi\bin directory.
delphi3:  mm.hlp file in you delphi3\help directory.
)

P/S If the above works but the sound is still no loud enough then I think you should change the pc speaker :-)

kjteng
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now