Solved

I need a beep  :-)

Posted on 2000-02-15
3
198 Views
Last Modified: 2011-09-20
hello
  I need te be abble to perform a beep on PC speaker with 2 parameters : frequency and duration.

Points will be upgraded to 200 for a full working answer today

Note :1) This  should work on W95/W98/NT
      2) The beep is sent to internal PCSpeaker even if there is a soundcard installed.

thanks for all ideas.

   HelpMe
0
Comment
Question by:helpme020897
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 2522248
Try this for Win95:

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

            if (B and 3) = 0 then
               begin
                   SetPort($61, Word(B or 3));
                   SetPort($43, $B6);
               end;

            SetPort($42, Freq);
            SetPort($42, Freq shr 8);
        end;
end;

procedure NoSound;
var
  Value: Word;
begin
    Value := GetPort($61) and $FC;
    SetPort($61, Value);
end;

procedure SetPort(address, Value:Word);
var
  bValue: byte;
begin
  bValue := trunc(Value and 255);
  asm
    mov dx, address
    mov al, bValue
    out dx, al
  end;
end;

function GetPort(address:word):word;
var
  bValue: byte;
begin
  asm
    mov dx, address
    in al, dx
    mov bValue, al
  end;
  GetPort := bValue;
end;

--------------------------------------------------------------------------------
Under WinNT, Beep(Tone, Duration) can be used. The Win32 help for beep also says it works in Win95.

Cheers,

Raymond.
0
 

Author Comment

by:helpme020897
ID: 2522358
Adjusted points to 200
0
 

Author Comment

by:helpme020897
ID: 2522359
Hi Raymond,
  First, thanks for your answer. I expected something more easy... but if there is no other solution...

  The WinApi beep function doesn't works under W95/98 i saw this in the help.. so as far as i know...


0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

16 Experts available now in Live!

Get 1:1 Help Now