Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Beep/ Sound in Delphi
2 comments. Current rating: (1 votes). Leave comments and/ or rate it.
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:
Windows.Beep(Frequency, Duration);
 | |  | | function InPort(PortAddr:word): byte; assembler; stdcall;
asm
mov dx,PortAddr
in al,dx
end;
procedure OutPort(PortAddr: word; Databyte: byte); assembler; stdcall;
asm
mov al,Databyte
mov dx,PortAddr
out dx,al
end;
procedure Sound(Hz : Word);
var TmpW : Word;
begin
OutPort($43,182);
TmpW :=InPort($61);
OutPort($61,TmpW or 3);
OutPort($42,lo(1193180 div hz));
OutPort($42, hi(1193180 div hz));
end;
procedure NoSound;
var TmpW : Word;
begin
OutPort($43,182);
TmpW := InPort($61);
OutPort($61,TmpW and 3);
end;
| |  | |  |
Comments:
|
anonymous from Germany
|
 |
|
|
This solved my problem with WinMe.
|
2007-04-04, 01:25:25 (updated: 2007-04-04, 01:28:20) |
anonymous from Iran
|
|
|
|
|
|