Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sound in delphi

Posted on 1998-02-16
3
Medium Priority
?
377 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

721 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