Solved

sound in delphi

Posted on 1998-02-16
3
337 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
ID: 1359383
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
ID: 1359384
Thanks!
ZifNab saved my life.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1359385
Woow, saved your life? Was it so badly needed?

Pitty, I don't live in Zurich.

c.u. Zif.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

862 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

23 Experts available now in Live!

Get 1:1 Help Now