Ne znam tuk ima li ogranichenie na razmera na otgoworite (mai niama):
unit UtilsSpkBeep;
interface
const
flSoundEnabled: boolean = true;
{}procedure Music1;
{}procedure Music2;
{}procedure SoundErrKey;
{}procedure Sound(Frequency, Duration: Integer);
{}procedure SoundFl(Frequency, Duration: Integer);
Const
Music1_Len=66;
//частоты
Music1_Frec : array[1..Music1_Len] of word=(
82,82,78,82,
87,82,73,65,
62,65,62,55,
110,104,110,124,
110,104,110,124,0,
131,124,110,104,
124,110,110,98,
93,82,98,87,
82,98,87,82,
73,65,62,55,
55,0,
131,124,110,104,
124,110,110,98,
87,82,98,87,
82,98,87,82,
73,0,
65,62,55,55,0
);
//длительности
Music1_Time : array[1..Music1_Len] of word=(
240,240,250,250,
250,750,250,250,
250,250,250,750,
500,250,250,250,
250,250,250,750,250,
250,250,250,250,
250,750,250,250,
250,250,250,750,
500,250,250,250,
250,250,250,250,
500,250,
250,250,250,250,
250,750,250,250,
250,250,250,750,
500,250,250,250,
250,10,
250,250,250,500,250
);
const
Music2_Len = 88;
Music2_Frec : array[1..Music2_Len] of word=(294,262,233,233,262,233,175,147,156,
156,196,175,147,175,233,262,294,294,294,262,233,262,
294,262,262,294,262,233,233,262,233,175,147,156,
175,196,175,147,175,233,262,294,349,349,294,233,262,
294,262,233,294,349,294,349,349,
294,349,294,349,311,392,311,392,392,
311,392,311,392,466,466,349,349,
294,294,262,233,262,294,349,392,
349,294,233,262,294,262,233,0);
Music2_Time : array[1..Music2_Len] of word=(125,125,250,125,125,125,125,125,125,
125,125,125,125,250,125,125,250,250,125,125,125,125,
250,250,250,125,125,250,125,125,125,125,125,125,
125,125,125,125,250,125,125,250,250,125,125,125,125,
250,250,500,125,250,125,250,250,
125,250,125,500,125,250,125,250,250,
125,250,125,500,250,250,250,250,
250,250,250,125,125,125,250,125,
125,125,125,125,250,250,250,250);
implementation
uses
Windows, SysUtils;
{}procedure Music1;
var
i: integer;
begin
for i:=1 to Music1_Len do begin
Sound(4*Music1_Frec, Music1_Time div 2);
end;
end;
{}procedure Music2;
var
i: integer;
begin
for i:=1 to Music2_Len do begin
Sound(2*Music2_Frec, Music2_Time);
end;
end;
{}procedure SoundErrKey;
begin
SoundFl(2400,20);
SoundFl(1200,10);
SoundFl(2400,20);
end;
{}procedure SoundFl(Frequency, Duration: Integer);
begin
if flSoundEnabled then begin
Sound(Frequency, Duration);
end;
end;
{}procedure Sound(Frequency, Duration: Integer);
asm
cmp Win32Platform, VER_PLATFORM_WIN32_NT
jne @@9X
push edx
push eax
call Windows.Beep
ret
@@9X:
push ebx
push edx
mov bx, ax
mov ax, 34DDh
mov dx, 0012h
cmp dx, bx
jnc @@2
div bx
mov bx, ax
in al, 61h
test al, 3
jnz @@1
or al, 3
out 61h, al
mov al, 0B6h
out 43h, al
@@1:
mov al, bl
out 42h, al
mov al, bh
out 42h, al
call Windows.Sleep
in al, 61h
and al, 0FCh
out 61h, al
jmp @@3
@@2:
pop edx
@@3:
pop ebx
end;
end.
|