Search results for 'Sound'. 1 post(s) found.
- 2007/09/20 How to play sounds on the PC Speaker ?
Here's an example of how to play simple Sounds on the PC speaker
procedure SetPort(address, Value: Word) ;
var
bValue: Byte;
begin
bValue := trunc(Value and 255) ;
asm
mov dx, address
mov al, bValue
out dx, al
end;
end;
function GetPort(address: Word): Word;
var
bValue: Byte;
begin
asm
mov dx, address
in al, dx
mov bValue, al
end;
GetPort := bValue;
end;
procedure Sound(aFreq, aDelay: Integer) ;
procedure DoSound(Freq: Word) ;
var
B: Byte;
begin
if Freq > 18 then
begin
Freq := Word(1193181 div Longint(Freq)) ;
B := Byte(GetPort($61)) ;
if (B and 3) = 0 then
begin
SetPort($61, Word(B or 3)) ;
SetPort($43, $B6) ;
end;
SetPort($42, Freq) ;
SetPort($42, Freq shr 8) ;
end;
end;
procedure Delay(MSecs: Integer) ;
var
FirstTickCount: LongInt;
begin
FirstTickCount := GetTickCount;
repeat
Sleep(1) ;
//or use Application.ProcessMessages instead of Sleep
until ((GetTickCount - FirstTickCount) >= Longint(MSecs)) ;
end;
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
Windows.Beep(aFreq, aDelay) ;
end
else
begin
DoSound(aFreq) ;
Delay(aDelay) ;
end;
end;
procedure NoSound;
var
Value: Word;
begin
if not (Win32Platform = VER_PLATFORM_WIN32_NT) then
begin
Value := GetPort($61) and $FC;
SetPort($61, Value) ;
end;
end;
{
// Example:
procedure TForm1.Button1Click(Sender: TObject) ;
begin
Sound(500, 1000) ;
Sound(700, 1000) ;
Sound(900, 1000) ;
NoSound;
end;
}
var
bValue: Byte;
begin
bValue := trunc(Value and 255) ;
asm
mov dx, address
mov al, bValue
out dx, al
end;
end;
function GetPort(address: Word): Word;
var
bValue: Byte;
begin
asm
mov dx, address
in al, dx
mov bValue, al
end;
GetPort := bValue;
end;
procedure Sound(aFreq, aDelay: Integer) ;
procedure DoSound(Freq: Word) ;
var
B: Byte;
begin
if Freq > 18 then
begin
Freq := Word(1193181 div Longint(Freq)) ;
B := Byte(GetPort($61)) ;
if (B and 3) = 0 then
begin
SetPort($61, Word(B or 3)) ;
SetPort($43, $B6) ;
end;
SetPort($42, Freq) ;
SetPort($42, Freq shr 8) ;
end;
end;
procedure Delay(MSecs: Integer) ;
var
FirstTickCount: LongInt;
begin
FirstTickCount := GetTickCount;
repeat
Sleep(1) ;
//or use Application.ProcessMessages instead of Sleep
until ((GetTickCount - FirstTickCount) >= Longint(MSecs)) ;
end;
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
Windows.Beep(aFreq, aDelay) ;
end
else
begin
DoSound(aFreq) ;
Delay(aDelay) ;
end;
end;
procedure NoSound;
var
Value: Word;
begin
if not (Win32Platform = VER_PLATFORM_WIN32_NT) then
begin
Value := GetPort($61) and $FC;
SetPort($61, Value) ;
end;
end;
{
// Example:
procedure TForm1.Button1Click(Sender: TObject) ;
begin
Sound(500, 1000) ;
Sound(700, 1000) ;
Sound(900, 1000) ;
NoSound;
end;
}
Another posts included in "Delphi"
| How to remove your application from TaskBar (0) | 2007/09/25 |
| How to track a user's idle time (0) | 2007/09/25 |
| How to know whether the font is TrueTypeFont or not (0) | 2007/09/25 |
| How to install an INF file using Delphi ? (0) | 2007/09/20 |
| How to determine the output of a console application ? (0) | 2007/09/20 |
| Get text from the control at pos x,y on screen (0) | 2007/09/20 |
| Get dimensions of usable space on monitor (work area) (0) | 2007/09/20 |
| Get system info (free memory, etc) (0) | 2007/09/20 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/29 01:04
moneyideas
-
Subject different money making ideas
2010/01/29 09:28
moneyideas
-
Subject different money making ideas
2010/01/31 16:41
moneyideas

Prev

Rss Feed