Solved

I need a beep  :-)

Posted on 2000-02-15
3
200 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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