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

x
?
Solved

sound in delphi

Posted on 1998-02-16
3
Medium Priority
?
383 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 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

927 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