Article View: borland.public.cppbuilder.multimedia
Article #234Re: Easiest way to beep the speakers
From: Simon Owen
Date: Sat, 25 Nov 2006 03:55
Date: Sat, 25 Nov 2006 03:55
47 lines
2320 bytes
2320 bytes
Right, dug out my old copy of PC intern for you.
void HardBeep(int Freq, int Duration)
{
OSVERSIONINFO osInfo;
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osInfo);
if( osInfo.dwMajorVersion >= 5 ||
osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT )
{
Beep(Freq,Duration);
return;
}
asm {
mov eax,1193181
xor edx,edx
mov ebx,dword ptr [Freq]
div ebx
pushd eax
mov al,182
out 0x43,al
pop eax
out 0x42,al
mov al,ah
out 0x42,al
in al,0x61
or al,3
out 0x61,al
}
Sleep(Duration);
asm {
in al,0x61
and al,0xfc
out 0x61,al
}
}
The above function basically does the Beep command under Win9x as it does
for NT and above. On an NT based system it simply calls the Beep command. If
under any NT system this produces a beep on the sound card, then its because
your sound card drivers are intercepting commands to the internal speaker in
an attempt to be helpful.
I've tested the above on WinXP and Win98 with an audigy sound card and the
sound card was never used.
Technical Details
Message-ID:
<4567bea7@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<45598de3@newsgroups.borland.com> <455d9fec$1@newsgroups.borland.com> <455df52f@newsgroups.borland.com> <4561b3e0@newsgroups.borland.com> <4561c1c9$1@newsgroups.borland.com> <4561e2db@newsgroups.borland.com> <456402fc@newsgroups.borland.com> <456415b2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10d0fc,48645038bf79d9cf X-Google-Attributes: gid10d0fc,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Simon Owen" <owensimon@ntlworld.com> Newsgroups: borland.public.cppbuilder.multimedia References: <45598de3@newsgroups.borland.com> <455d9fec$1@newsgroups.borland.com> <455df52f@newsgroups.borland.com> <4561b3e0@newsgroups.borland.com> <4561c1c9$1@newsgroups.borland.com> <4561e2db@newsgroups.borland.com> <456402fc@newsgroups.borland.com> <456415b2@newsgroups.borland.com> Subject: Re: Easiest way to beep the speakers Date: Sat, 25 Nov 2006 03:55:25 -0000 Lines: 49 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 81.98.153.84 Message-ID: <4567bea7@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1164426919 81.98.153.84 (24 Nov 2006 19:55:19 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail