Solved

sound in delphi

Posted on 1998-02-16
3
327 Views
Last Modified: 2010-04-04
Is there a way to program sound in Delphi in a manner similar to the Pascal line: "sound(frequency)" followed by
"nosound"  ?? I do not want to use *.wav type files.
0
Comment
Question by:casal
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
Comment Utility
Yep, there is :

Found them some time ago on the net,

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
 

Author Comment

by:casal
Comment Utility
Thanks!
ZifNab saved my life.
0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
Woow, saved your life? Was it so badly needed?

Pitty, I don't live in Zurich.

c.u. Zif.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

14 Experts available now in Live!

Get 1:1 Help Now