Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to use a Beep / Sound in Delphi Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
11-Sep-02
Category
Multimedia
Language
Delphi All Versions
Views
91
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert

Beep/Sound in Delphi

Answer:

The following assembler Routines implement sound output via port access and work 
therefore only with Win3.x and Win95/98. Simply call Sound(hz) with hz as frequency 
in Hz, and stop the sound output with NoSound().

If your application will run under Windows NT, you may use the operating system 
routine:

1   Windows.Beep(Frequency, Duration);
2   
3   
4   function InPort(PortAddr: word): byte; assembler; stdcall;
5   asm
6     mov dx,PortAddr
7     in al,dx
8   end;
9   
10  procedure OutPort(PortAddr: word; Databyte: byte); assembler; stdcall;
11  asm
12    mov al,Databyte
13    mov dx,PortAddr
14    out dx,al
15  end;
16  
17  procedure Sound(Hz: Word);
18  var
19    TmpW: Word;
20  begin
21    OutPort($43, 182);
22    TmpW := InPort($61);
23    OutPort($61, TmpW or 3);
24    OutPort($42, lo(1193180 div hz));
25    OutPort($42, hi(1193180 div hz));
26  end;
27  
28  procedure NoSound;
29  var
30    TmpW: Word;
31  begin
32    OutPort($43, 182);
33    TmpW := InPort($61);
34    OutPort($61, TmpW and 3);
35  end;




			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC