Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PC Speakers

Posted on 1998-06-08
8
Medium Priority
?
531 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 60 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses

916 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