Solved

PC Speakers

Posted on 1998-06-08
8
527 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 119
Virtuailstring tree compare node issue 14 125
SUM 2 INTEGER ARRAYS INTO 1 10 108
Moving (cutting/pasting) controls in a TTabbedNotebook... 7 44
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

830 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